aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/tests/QtAsyncio
Commit message (Collapse)AuthorAgeFilesLines
* QtAsyncio: Include this non-Qt module into normal testingFriedemann Kleint2025-07-0712-14/+101
| | | | | | | | | | | QtAsyncio has tests like other modules, although they were not automatically tested. Add a way to specify this kind of modules without conflicts in cmake. Initial-patch-by: Christian Tismer <tismer@stackless.com> Task-number: PYSIDE-769 Change-Id: I9897f37c98c400846af77d18533486fb048aca80 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* QtAsyncio: Add clarifying commentsAdrian Herrmann2024-07-191-0/+10
| | | | | | | | | | | Add a few more clarifying comments regarding to previous bug fixes or non-obvious variable usages. Pick-to: 6.7 Task-number: PYSIDE-2644 Task-number: PYSIDE-769 Change-Id: Ic4db10510e1adf8141efa83d727f519547d67b24 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* QtAsyncio: Skip CancelTaskGroup test for < 3.11Adrian Herrmann2024-07-191-1/+3
| | | | | | | | | | Skip the QAsyncioTestCaseCancelTaskGroup unit test for versions below 3.11, as ExceptionGroup was only added with 3.11. Pick-to: 6.7 Task-number: PYSIDE-769 Change-Id: I572c26333a523bc14626d2bfa6dc5e37a581c517 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* QtAsyncio: Don't cancel handleAdrian Herrmann2024-07-161-0/+30
| | | | | | | | | | | | | | | It is not necessary to cancel a task's handle when cancelling said task, as the step function already handles the cancellation. Furthermore, cancelling the handle can cause issues with TaskGroups if an exception is raised inside the TaskGroup's context, where the tasks inside the group are not allowed to properly cancel and thus block the program. Pick-to: 6.7 Task-number: PYSIDE-769 Fixes: PYSIDE-2799 Change-Id: I1ab782380ffbe8c1ec40aba22b9ed2ebdcb1498f Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* QtAsyncio: Add cancel count and uncancelAdrian Herrmann2024-07-162-0/+108
| | | | | | | | | | | | | | | | Implement the QAsyncioTask.uncancel() function and the associated cancel count. Note to reader: Unlike what the name suggests, the uncancel() function on its own does not undo a task cancellation. This must be performed by consuming the CancelledError exception, at which point uncancel() serves to remove the cancellation state. Pick-to: 6.7 Task-number: PYSIDE-769 Fixes: PYSIDE-2790 Change-Id: I4e817e1dd3f49179855432d20ed2f043090fd8f1 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Python-3.10: Allow the new syntax for Python 3.9Christian Tismer2024-06-208-0/+8
| | | | | | | | Add a future statement to all Python source files. Task-number: PYSIDE-2786 Change-Id: Icd6688c7795a9e16fdcaa829686d57792df27690 Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io>
* QtAsyncio: Fix tasks with loop not cancellingAdrian Herrmann2024-04-221-0/+57
| | | | | | | | | | | | | | | If a task was cancelled, then a new future created from this task should be cancelled as well. Otherwise, in some scenarios like a loop inside the task and with bad timing, if the new future is not cancelled, the task would continue running in this loop despite having been cancelled. This bad timing can occur especially if the first future finishes very quickly. Pick-to: 6.7 Fixes: PYSIDE-2644 Task-number: PYSIDE-769 Change-Id: Icfff6e4ad5da565f50e3d89fbf85d1fecbf93650 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* QtAsyncio: Shorten test durationsAdrian Herrmann2024-01-076-12/+15
| | | | | | | | | | | Most QtAsyncio tests are slow because they sleeps. Shorten their durations across the board by using shorter sleeps. E.g., this reduces the duration of the queue test from about 16 seconds to less than 6. Pick-to: 6.6 Task-number: PYSIDE-769 Change-Id: I5072bb71fbe28509427fb92390584ec1a4d1a128 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* QtAsyncio: Fix cancelling waiting tasksAdrian Herrmann2024-01-071-0/+46
| | | | | | | | | | A task that is awaiting a future must also cancel this future in order for the cancellation to be successful. Pick-to: 6.6 Task-number: PYSIDE-769 Change-Id: I22a9132fc8506e7a007fe625bc9217f0760bdc6b Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* QtAsyncio: Implement call_soon_threadsafe()Adrian Herrmann2023-12-141-0/+58
| | | | | | | | | | | | | | | Using the QTimer.singleShot(msec, context, functor) overload in QAsyncioHandle already turned call_soon() threadsafe, as that allowed callbacks to be scheduled from other threads. In order to follow the API and distinguish call_soon() and call_soon_threadsafe(), the former is reverted to using the old overload without the context argument, while the latter keeps the new overload. Pick-to: 6.6 Task-number: PYSIDE-769 Change-Id: Ib2591f994d082b46fe4ec747e590e4d8eb6ff24e Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
* QtAsyncio: Add wrapper for calls in executorAdrian Herrmann2023-11-241-0/+46
| | | | | | | | | | | | | | | Executors require a bit of extra work for QtAsyncio, as we can't use naked Python threads, instead we must make sure that the thread created by executor.submit() has an event loop. This is achieved by submitting a small wrapper that attaches a QEventLoop to the executor thread, and then creates a singleshot timer to push the actual function for the executor into this new event loop. Pick-to: 6.6 Task-number: PYSIDE-769 Change-Id: I77569d8939d6040ddbe62a99448c6ced2785f27e Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
* QtAsyncio: Add queues testAdrian Herrmann2023-09-121-0/+68
| | | | | | | | | | Add a test for the asyncio queue for consumer/producer scenarios. Additionally, fix a few bugs exposed by this test through the increased code coverage. Task-number: PYSIDE-769 Change-Id: I18e3be6d059b758868a7598b58704db216bcdcc8 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* QtAsyncio: Fix time unitAdrian Herrmann2023-09-122-1/+50
| | | | | | | | | loop.time() needs to return the time in seconds as a float, not in milliseconds as an int. Task-number: PYSIDE-769 Change-Id: Iac123132b49d3954abda8545d0830f1837a27c48 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Implement custom asyncio event loop based on QtAdrian Herrmann2023-07-274-0/+113
asyncio is an established library for Python applications with concurrency and asynchronous I/O, and the de facto standard that multiple other async frameworks build upon. Like Qt, it is based on an event loop, so to this end, it offers an extensive API to implement custom event loops that applications using asyncio can then leverage. Task-number: PYSIDE-769 Change-Id: I3daf5d631e2fa0d44fd8c3c272ac5cce96f58653 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>