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

Blocked detector #5

Closed
wants to merge 68 commits into from
Closed

Blocked detector #5

wants to merge 68 commits into from

Conversation

komuw
Copy link
Owner

@komuw komuw commented Feb 23, 2019

Thank you for contributing to xyzabc.
Every contribution to xyzabc is important.

Contributor offers to license certain software (a “Contribution” or multiple
“Contributions”) to xyzabc, and xyzabc agrees to accept said Contributions,
under the terms of the MIT License.
Contributor understands and agrees that xyzabc shall have the irrevocable and perpetual right to make
and distribute copies of any Contribution, as well as to create and distribute collective works and
derivative works of any Contribution, under the MIT License.

Now,

What(What have you changed?)

Why(Why did you change it?)

References:

@komuw
Copy link
Owner Author

komuw commented Feb 23, 2019

def BLOCKING_DISK_IO(the_broker) -> xyzabc.task.Task:
    class BlockingDiskIOTask(xyzabc.task.Task):
        async def async_run(self, *args, **kwargs):
            print()
            print("RUNNING BlockingDiskIOTask:")
            import subprocess

            subprocess.run(["dd", "if=/dev/zero", "of=/dev/null", "bs=500000", "count=1000000"])

    task = BlockingDiskIOTask(
        the_broker=the_broker,
        queue_name="BlockingDiskIOTask",
        eta=60.0,
        retries=3,
        log_id="myLogID",
        hook_metadata='{"email": "example@example.com"}',
    )
    return task

@komuw
Copy link
Owner Author

komuw commented Feb 23, 2019

For the blocking disk IO task above, the TaskBlocker Watchdog generates this stack trace:

File "cli/cli.py", line 327, in <module>
    asyncio.run(async_main(), debug=True)

  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/runners.py", line 43, in run
    return loop.run_until_complete(main)

  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py", line 555, in run_until_complete
    self.run_forever()

  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py", line 523, in run_forever
    self._run_once()

  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py", line 1750, in _run_once
    handle._run()

  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)

  File "/Users/komuw/mystuff/xyzabc/xyzabc/worker.py", line 222, in consume_forever
    await self.run(*task_args, **task_kwargs)

  File "/Users/komuw/mystuff/xyzabc/xyzabc/worker.py", line 123, in run
    return_value = await self.the_task.async_run(*task_args, **task_kwargs)

  File "cli/cli.py", line 79, in async_run
    subprocess.run(["dd", "if=/dev/zero", "of=/dev/null", "bs=500000", "count=1000000"])

  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 455, in run
    stdout, stderr = process.communicate(input, timeout=timeout)

  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 912, in communicate
    self.wait()

  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 971, in wait
    return self._wait(timeout=timeout)

  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1601, in _wait
    (pid, sts) = self._try_wait(0)

  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1559, in _try_wait
    (pid, sts) = os.waitpid(self.pid, wait_flags)

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.

validate that code inside Task.async_run is not blocking
1 participant