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

test_no_exceptions_when_cancel_pending_request failing on macos #2298

Closed
risicle opened this issue Nov 5, 2021 · 2 comments
Closed

test_no_exceptions_when_cancel_pending_request failing on macos #2298

risicle opened this issue Nov 5, 2021 · 2 comments
Labels

Comments

@risicle
Copy link

risicle commented Nov 5, 2021

Describe the bug
Sanic 21.9.1 on macos 10.15 & python 3.8.12, test_no_exceptions_when_cancel_pending_request fails with a familiar:

―――――――――――――――― test_no_exceptions_when_cancel_pending_request ――――――――――――――――

app = Sanic(name="test_no_exceptions_when_cancel_pending_request")
caplog = <_pytest.logging.LogCaptureFixture object at 0x112edc7f0>

    def test_no_exceptions_when_cancel_pending_request(app, caplog):
        app.config.GRACEFUL_SHUTDOWN_TIMEOUT = 1

        @app.get("/")
        async def handler(request):
            await asyncio.sleep(5)

        @app.after_server_start
        def shutdown(app, _):
            time.sleep(0.2)
            app.stop()

        def ping():
            time.sleep(0.1)
            response = httpx.get("http://127.0.0.1:8000")
            print(response.status_code)

        p = Process(target=ping)
>       p.start()

tests/test_graceful_shutdown.py:32:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/nix/store/9h7xr11my83hh41m5p1cidnjywa67i2p-python3-3.8.12/lib/python3.8/multiprocessing/process.py:121: in start
    self._popen = self._Popen(self)
/nix/store/9h7xr11my83hh41m5p1cidnjywa67i2p-python3-3.8.12/lib/python3.8/multiprocessing/context.py:224: in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
/nix/store/9h7xr11my83hh41m5p1cidnjywa67i2p-python3-3.8.12/lib/python3.8/multiprocessing/context.py:284: in _Popen
    return Popen(process_obj)
/nix/store/9h7xr11my83hh41m5p1cidnjywa67i2p-python3-3.8.12/lib/python3.8/multiprocessing/popen_spawn_posix.py:32: in __init__
    super().__init__(process_obj)
/nix/store/9h7xr11my83hh41m5p1cidnjywa67i2p-python3-3.8.12/lib/python3.8/multiprocessing/popen_fork.py:19: in __init__
    self._launch(process_obj)
/nix/store/9h7xr11my83hh41m5p1cidnjywa67i2p-python3-3.8.12/lib/python3.8/multiprocessing/popen_spawn_posix.py:47: in _launch
    reduction.dump(process_obj, fp)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

obj = <Process name='Process-1' parent=68540 initial>
file = <_io.BytesIO object at 0x112e7e400>, protocol = None

    def dump(obj, file, protocol=None):
        '''Replacement for pickle.dump() using ForkingPickler.'''
>       ForkingPickler(file, protocol).dump(obj)
E       AttributeError: Can't pickle local object 'test_no_exceptions_when_cancel_pending_request.<locals>.ping'

/nix/store/9h7xr11my83hh41m5p1cidnjywa67i2p-python3-3.8.12/lib/python3.8/multiprocessing/reduction.py:60: AttributeError

which is very reminiscent of #1774. Would be interested to know if you can reproduce this. (I would just look at your CI but it doesn't seem you run CI against macos)

@ahopkins
Copy link
Member

ahopkins commented Nov 7, 2021

Would be interested to know if you can reproduce this. (I would just look at your CI but it doesn't seem you run CI against macos)

🤔 We did. I'll have to double check that why it's happening. Any time this has come up its usually been the case of nested funcs. But MacOS is not the only platform incapable of handling that do it should happen elsewhere as well.

Thanks for bringing this up. Will look into it.

@stale
Copy link

stale bot commented Mar 2, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is incorrect, please respond with an update. Thank you for your contributions.

@stale stale bot added the stale label Mar 2, 2022
@stale stale bot closed this as completed Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants