ez-a-sync 0.32.10__cp313-cp313-musllinux_1_2_i686.whl → 0.32.11__cp313-cp313-musllinux_1_2_i686.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ez-a-sync might be problematic. Click here for more details.

a_sync/_smart.pyx CHANGED
@@ -9,14 +9,15 @@ import asyncio
9
9
  import typing
10
10
  import weakref
11
11
  from logging import getLogger
12
+ from types import TracebackType
12
13
 
13
14
  cimport cython
14
15
  from cpython.object cimport PyObject
15
16
  from cpython.ref cimport Py_DECREF, Py_INCREF
16
17
 
17
- from a_sync._typing import *
18
+ from a_sync._typing import T
18
19
 
19
- if TYPE_CHECKING:
20
+ if typing.TYPE_CHECKING:
20
21
  from a_sync import SmartProcessingQueue
21
22
 
22
23
  cdef extern from "weakrefobject.h":
@@ -50,6 +51,7 @@ del getLogger
50
51
  cdef object Any = typing.Any
51
52
  cdef object Generic = typing.Generic
52
53
  cdef object Tuple = typing.Tuple
54
+ cdef object Union = typing.Union
53
55
  del typing
54
56
 
55
57
 
@@ -173,7 +175,7 @@ cdef inline bint _is_cancelled(fut: Future):
173
175
 
174
176
 
175
177
  @cython.linetrace(False)
176
- cdef object _get_result(fut: Future):
178
+ cdef object _get_result(fut: Union["SmartFuture", "SmartTask"]):
177
179
  """Return the result this future represents.
178
180
 
179
181
  If the future has been cancelled, raises CancelledError. If the
@@ -185,7 +187,11 @@ cdef object _get_result(fut: Future):
185
187
  fut._Future__log_traceback = False
186
188
  exc = fut._exception
187
189
  if exc is not None:
188
- raise exc.with_traceback(exc.__traceback__)
190
+ cached_traceback = fut.__traceback__
191
+ if cached_traceback is None:
192
+ cached_traceback = exc.__traceback__
193
+ fut.__traceback__ = cached_traceback
194
+ raise exc.with_traceback(cached_traceback) from exc.__cause__
189
195
  return fut._result
190
196
  if state == "CANCELLED":
191
197
  raise fut._make_cancelled_error()
@@ -230,6 +236,8 @@ class SmartFuture(Future, Generic[T]):
230
236
  _key: Optional[Key] = None
231
237
 
232
238
  _waiters: "weakref.WeakSet[SmartTask[T]]"
239
+
240
+ __traceback__: Optional[TracebackType] = None
233
241
 
234
242
  def __init__(
235
243
  self,
@@ -408,7 +416,10 @@ class SmartTask(Task, Generic[T]):
408
416
  See Also:
409
417
  - :class:`asyncio.Task`
410
418
  """
419
+
411
420
  _waiters: Set["Task[T]"]
421
+
422
+ __traceback__: Optional[TracebackType] = None
412
423
 
413
424
  @cython.linetrace(False)
414
425
  def __init__(
@@ -623,7 +634,7 @@ cdef tuple _get_done_callbacks(inner: Task, outer: Future):
623
634
  if _is_cancelled(outer):
624
635
  if not _is_cancelled(inner):
625
636
  # Mark inner's result as retrieved.
626
- _get_exception(inner)
637
+ inner._Future__log_traceback = False
627
638
  return
628
639
 
629
640
  if _is_cancelled(inner):
@@ -633,7 +644,7 @@ cdef tuple _get_done_callbacks(inner: Task, outer: Future):
633
644
  if exc is not None:
634
645
  outer.set_exception(exc)
635
646
  else:
636
- outer.set_result(_get_result(inner))
647
+ outer.set_result(inner._result)
637
648
 
638
649
  def _outer_done_callback(outer):
639
650
  if _is_not_done(inner):