komuw / wiji

Wiji is an asyncio distributed task processor/queue.
MIT License
4 stars 1 forks source link

Blocked detector #5

Closed komuw closed 5 years ago

komuw commented 5 years ago

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 commented 5 years ago
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 commented 5 years ago

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)