Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(6058)

Issue 110030043: Enable debug mode of event loops when PYTHONASYNCIODEBUG is set

Can't Edit
Can't Publish+Mail
Start Review
Created:
9 years, 10 months ago by haypo_gmail
Modified:
9 years, 10 months ago
Reviewers:
GvR
Visibility:
Public.

Description

Enable debug mode of event loops when PYTHONASYNCIODEBUG is set

Patch Set 1 #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+33 lines, -23 lines) Patch
M asyncio/base_events.py View 1 chunk +2 lines, -1 line 0 comments Download
M asyncio/proactor_events.py View 1 chunk +3 lines, -1 line 2 comments Download
M asyncio/test_utils.py View 1 chunk +8 lines, -2 lines 2 comments Download
M tests/test_proactor_events.py View 1 chunk +3 lines, -3 lines 0 comments Download
M tests/test_selector_events.py View 1 chunk +0 lines, -2 lines 0 comments Download
M tests/test_streams.py View 1 chunk +2 lines, -1 line 0 comments Download
M tests/test_subprocess.py View 2 chunks +12 lines, -5 lines 0 comments Download
M tests/test_tasks.py View 1 chunk +3 lines, -0 lines 0 comments Download
M tests/test_unix_events.py View 4 chunks +0 lines, -8 lines 0 comments Download

Messages

Total messages: 3
GvR
I'm not sure I understand the reason for these changes. Why can't you have the ...
9 years, 10 months ago (2014-06-18 03:53:36 UTC) #1
haypo_gmail
On 2014/06/18 03:53:36, GvR wrote: > I'm not sure I understand the reason for these ...
9 years, 10 months ago (2014-06-18 09:24:34 UTC) #2
haypo_gmail
9 years, 10 months ago (2014-06-18 09:24:40 UTC) #3
https://codereview.appspot.com/110030043/diff/1/asyncio/proactor_events.py
File asyncio/proactor_events.py (right):

https://codereview.appspot.com/110030043/diff/1/asyncio/proactor_events.py#ne...
asyncio/proactor_events.py:404: # from the event loop constructor
On 2014/06/18 03:53:36, GvR wrote:
> I don't understand this.

Example:
---
import socket
from asyncio.proactor_events import BaseProactorEventLoop

sock = mock.Mock(socket.socket)
proactor = mock.Mock()

ssock, csock = mock.Mock(), mock.Mock()

class EventLoop(BaseProactorEventLoop):
    def _socketpair(s):
        return (ssock, csock)

loop = EventLoop(proactor)
---

If the _debug set is initialized to True in the constructor, you get this
traceback:
---
Traceback (most recent call last):
  File "x.py", line 14, in <module>
    loop = EventLoop(proactor)
  File "/home/haypo/prog/HG/tulip/asyncio/proactor_events.py", line 333, in
__init__
    self._make_self_pipe()
  File "/home/haypo/prog/HG/tulip/asyncio/proactor_events.py", line 403, in
_make_self_pipe
    self.call_soon(self._loop_self_reading)
  File "/home/haypo/prog/HG/tulip/asyncio/base_events.py", line 297, in
call_soon
    return self._call_soon(callback, args, check_loop=True)
  File "/home/haypo/prog/HG/tulip/asyncio/base_events.py", line 303, in
_call_soon
    self._assert_is_current_event_loop()
  File "/home/haypo/prog/HG/tulip/asyncio/base_events.py", line 319, in
_assert_is_current_event_loop
    "non-threadsafe operation invoked on an event loop other "
RuntimeError: non-threadsafe operation invoked on an event loop other than the
current one
---

https://codereview.appspot.com/110030043/diff/1/asyncio/test_utils.py
File asyncio/test_utils.py (right):

https://codereview.appspot.com/110030043/diff/1/asyncio/test_utils.py#newcode390
asyncio/test_utils.py:390: # in debug mode, the current event loop is checked
On 2014/06/18 03:53:36, GvR wrote:
> This seems wrong.

If _debug is initialized to True in BaseEventLoop constructor and the event loop
of the current policy is set to None, calls to call_soon() (and similar
functions) fail. Example of traceback:

Traceback (most recent call last):
  ...
  File "/home/haypo/prog/HG/tulip/asyncio/futures.py", line 301, in set_result
    self._schedule_callbacks()
  File "/home/haypo/prog/HG/tulip/asyncio/futures.py", line 211, in
_schedule_callbacks
    self._loop.call_soon(callback, self)
  File "/home/haypo/prog/HG/tulip/asyncio/base_events.py", line 298, in
call_soon
    return self._call_soon(callback, args, check_loop=True)
  File "/home/haypo/prog/HG/tulip/asyncio/base_events.py", line 304, in
_call_soon
    self._assert_is_current_event_loop()
  File "/home/haypo/prog/HG/tulip/asyncio/base_events.py", line 318, in
_assert_is_current_event_loop
    if events.get_event_loop() is not self:
  File "/home/haypo/prog/HG/tulip/asyncio/events.py", line 503, in
get_event_loop
    return get_event_loop_policy().get_event_loop()
  File "/home/haypo/prog/HG/tulip/asyncio/events.py", line 449, in
get_event_loop
    threading.current_thread().name)
AssertionError: There is no current event loop in thread 'MainThread'.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b