Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow pausing of code in the event loop #1003

Merged
merged 1 commit into from
May 27, 2024
Merged

Conversation

bdieterm
Copy link
Collaborator

I have removed a restriction for pausing executed code so that gui event loops can also be paused.

Code for testing:

import time
import os

if __pyzo__.guiName == 'PYSIDE6':

    os.environ['PYZO_PROCESS_EVENTS_WHILE_DEBUGGING'] = '0'

    from PySide6 import QtGui, QtCore, QtWidgets

    cnt = 0
    def callback_timer():
        global cnt
        print('event loop', cnt)
        cnt += 1
        if cnt > 10:
            my_timer.stop()
            print('finished')

    my_timer = QtCore.QTimer()
    my_timer.timeout.connect(callback_timer)
    my_timer.start(500)

elif __pyzo__.guiName == 'ASYNCIO':

    import asyncio

    def bar():
        for cnt in range(10):
            print('event loop', cnt)
            time.sleep(0.5)
        print('finished')

    loop = asyncio.get_running_loop()
    loop.call_soon(bar)


print('press pause now to interrupt regular script')
for a in range(10):
    print(chr(ord('a') + a))
    time.sleep(0.5)

print('press pause now to interrupt event loop stuff')

Note that, after merging this commit, "Pause" can be activated even when running no code at all. But in that case, it does not matter if the user then continues or stops execution in the debugger mode.

For the given example, I have seen that pausing in asyncio event loops mostly stops in the user's code, and sometimes in Python's asyncio library. Pausing in PySide6 event loops mostly stops in Pyzo's yoton library.

@bdieterm bdieterm merged commit d31a926 into pyzo:main May 27, 2024
16 checks passed
@bdieterm bdieterm deleted the improvePause branch June 23, 2024 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant