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

Add main_thread_only execmodel #243

Commits on Feb 20, 2024

  1. Add main_thread_only execmodel

    In order to prevent tasks from running in a non-main thread,
    wait for the previous task inside _try_send_to_primary_thread,
    then schedule the next task. Add a main_thread_only execmodel
    to distinguish this new behavior from the existing thread
    execmodel, since users of the thread execmodel expect that
    tasks can run in multiple threads concurrently. If concurrent
    remote_exec requests are submitted for the main_thread_only
    execmodel, then the channel will raise a RemoteError with
    this message:
    
        concurrent remote_exec would cause deadlock for main_thread_only execmodel
    
    In order for main_thread_only users to avoid this error,
    remote_exec callers must use the returned channel to wait
    for a task to complete before they call remote_exec again,
    as demonstrated in test_assert_main_thread_only. Testing of
    main_thread_only with pytest-xdist has shown that this behavior
    is compatible with the existing pytest-xdist usage because it
    never calls remote_exec more than once per gateway.
    zmedico committed Feb 20, 2024
    Configuration menu
    Copy the full SHA
    6b87f99 View commit details
    Browse the repository at this point in the history
  2. Popen2IO: Fix "Bad file descriptor" error

    Fix init_popen_io to leave behind a sane state (0 and 1 file
    descriptors open), in order to prevent "Bad file descriptor"
    errors. Also fix test_stdouterrin_setnull to restore stdin
    state, while relying on capfd to do this for stdout and stderr.
    
    The "Bad file descriptor" error doesn't trigger reliably
    because it's triggered by garbage collection of the Popen2IO
    instance returned from init_popen_io as shown in this job:
    
    https://github.com/pytest-dev/execnet/actions/runs/7955155978/job/21716386705?pr=243
    
    =================================== FAILURES ===================================
    __________________ test_stdouterrin_setnull[main_thread_only] __________________
    
    execmodel = <ExecModel 'main_thread_only'>
    capfd = <_pytest.capture.CaptureFixture object at 0x7fba8c333990>
    
        @pytest.mark.skipif("not hasattr(os, 'dup')")
        def test_stdouterrin_setnull(execmodel, capfd):
            gateway_base.init_popen_io(execmodel)
            os.write(1, b"hello")
    >       os.read(0, 1)
    E       OSError: [Errno 9] Bad file descriptor
    
    testing/test_basics.py:254: OSError
    zmedico committed Feb 20, 2024
    Configuration menu
    Copy the full SHA
    8f7f3a0 View commit details
    Browse the repository at this point in the history

Commits on Feb 22, 2024

  1. Add pytest-dev#243 to CHANGELOG

    zmedico committed Feb 22, 2024
    Configuration menu
    Copy the full SHA
    c5cef44 View commit details
    Browse the repository at this point in the history

Commits on Feb 24, 2024

  1. Merge branch 'master' into fix_issue_95_WorkerPool_Wait_for_previous_…

    …task_in_try_send_to_primary_thread
    RonnyPfannschmidt authored Feb 24, 2024
    Configuration menu
    Copy the full SHA
    772da33 View commit details
    Browse the repository at this point in the history