koil 3.3.2__tar.gz → 3.3.4__tar.gz
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.
- {koil-3.3.2 → koil-3.3.4}/PKG-INFO +2 -2
- {koil-3.3.2 → koil-3.3.4}/koil/qt.py +19 -19
- {koil-3.3.2 → koil-3.3.4}/pyproject.toml +1 -1
- {koil-3.3.2 → koil-3.3.4}/.gitignore +0 -0
- {koil-3.3.2 → koil-3.3.4}/README.md +0 -0
- {koil-3.3.2 → koil-3.3.4}/koil/__init__.py +0 -0
- {koil-3.3.2 → koil-3.3.4}/koil/bridge.py +0 -0
- {koil-3.3.2 → koil-3.3.4}/koil/composition/__init__.py +0 -0
- {koil-3.3.2 → koil-3.3.4}/koil/composition/base.py +0 -0
- {koil-3.3.2 → koil-3.3.4}/koil/context.py +0 -0
- {koil-3.3.2 → koil-3.3.4}/koil/contrib/__init__.py +0 -0
- {koil-3.3.2 → koil-3.3.4}/koil/contrib/pytest.py +0 -0
- {koil-3.3.2 → koil-3.3.4}/koil/contrib/pytest_qt.py +0 -0
- {koil-3.3.2 → koil-3.3.4}/koil/decorators.py +0 -0
- {koil-3.3.2 → koil-3.3.4}/koil/errors.py +0 -0
- {koil-3.3.2 → koil-3.3.4}/koil/helpers.py +0 -0
- {koil-3.3.2 → koil-3.3.4}/koil/koil.py +0 -0
- {koil-3.3.2 → koil-3.3.4}/koil/loop.py +0 -0
- {koil-3.3.2 → koil-3.3.4}/koil/protocols.py +0 -0
- {koil-3.3.2 → koil-3.3.4}/koil/py.typed +0 -0
- {koil-3.3.2 → koil-3.3.4}/koil/tracebacks.py +0 -0
- {koil-3.3.2 → koil-3.3.4}/koil/types.py +0 -0
- {koil-3.3.2 → koil-3.3.4}/koil/utils.py +0 -0
- {koil-3.3.2 → koil-3.3.4}/koil/vars.py +0 -0
|
@@ -214,10 +214,12 @@ class qt_to_async(QtCore.QObject, Generic[T, P]):
|
|
|
214
214
|
qtfuture, args, kwargs, ctx = typed_tuple
|
|
215
215
|
|
|
216
216
|
try:
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
217
|
+
# ``ctx.run`` rather than setting each var: this runs on the Qt main
|
|
218
|
+
# thread, which outlives every call on it. Bare ``.set()`` left the
|
|
219
|
+
# caller's values there forever, so the next slot -- belonging to
|
|
220
|
+
# another caller, or to none -- read whatever the last one happened
|
|
221
|
+
# to leave behind.
|
|
222
|
+
ctx.run(self.coro, qtfuture, *args, **kwargs) # type: ignore
|
|
221
223
|
|
|
222
224
|
except Exception as e:
|
|
223
225
|
logger.error(
|
|
@@ -238,8 +240,8 @@ class qt_to_async(QtCore.QObject, Generic[T, P]):
|
|
|
238
240
|
else:
|
|
239
241
|
context, x = await qtfuture.aiofuture
|
|
240
242
|
|
|
241
|
-
for
|
|
242
|
-
|
|
243
|
+
for var, value in context.items():
|
|
244
|
+
var.set(value)
|
|
243
245
|
|
|
244
246
|
return x
|
|
245
247
|
|
|
@@ -278,10 +280,9 @@ class qt_gen_to_async_gen(QtCore.QObject, Generic[T, P]):
|
|
|
278
280
|
qtgenerator, args, kwargs, ctx = typed_tuple
|
|
279
281
|
|
|
280
282
|
try:
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
self.coro(qtgenerator, *args, **kwargs) # type: ignore
|
|
283
|
+
# Scoped to the call, not left on the Qt main thread -- see
|
|
284
|
+
# ``qt_to_async.on_called``.
|
|
285
|
+
ctx.run(self.coro, qtgenerator, *args, **kwargs) # type: ignore
|
|
285
286
|
|
|
286
287
|
except Exception as e:
|
|
287
288
|
logger.error(
|
|
@@ -304,8 +305,8 @@ class qt_gen_to_async_gen(QtCore.QObject, Generic[T, P]):
|
|
|
304
305
|
else:
|
|
305
306
|
context, result = await qtgenerator.nextfuture
|
|
306
307
|
|
|
307
|
-
for
|
|
308
|
-
|
|
308
|
+
for var, value in context.items():
|
|
309
|
+
var.set(value)
|
|
309
310
|
|
|
310
311
|
yield result
|
|
311
312
|
|
|
@@ -349,9 +350,10 @@ class async_to_qt(QtCore.QObject, Generic[T, P]):
|
|
|
349
350
|
def on_returnedwithoutcontext(self, answer: Tuple[T, contextvars.Context]):
|
|
350
351
|
res, ctxs = answer
|
|
351
352
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
353
|
+
# The coroutine's context is made visible to whoever handles `returned`,
|
|
354
|
+
# and then unwound. Setting it on the Qt main thread instead would leave
|
|
355
|
+
# it there for every later slot -- the thread outlives the call.
|
|
356
|
+
ctxs.run(self.returned.emit, res)
|
|
355
357
|
|
|
356
358
|
def run(self, *args: P.args, **kwargs: P.kwargs) -> KoilFuture[T]:
|
|
357
359
|
koil_loop = get_koiled_loop_or_raise()
|
|
@@ -415,10 +417,8 @@ class async_gen_to_qt(QtCore.QObject, Generic[T, P]):
|
|
|
415
417
|
def on_yieldedwithoutcontext(self, answer: Tuple[T, contextvars.Context]):
|
|
416
418
|
res, ctxs = answer
|
|
417
419
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
self.yielded.emit(res)
|
|
420
|
+
# Scoped to the emit -- see `async_to_qt.on_returnedwithoutcontext`.
|
|
421
|
+
ctxs.run(self.yielded.emit, res)
|
|
422
422
|
|
|
423
423
|
def run(self, *args: P.args, **kwargs: P.kwargs) -> KoilFuture[None]:
|
|
424
424
|
koil_loop = get_koiled_loop_or_raise()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|