Keyboard Shortcuts

File
u :up to issue
m :publish + mail comments
M :edit review message
j / k :jump to file after / before current file
J / K :jump to next file with a comment after / before current file
Side-by-side diff
i :toggle intra-line diffs
e :expand all comments
c :collapse all comments
s :toggle showing all comments
n / p :next / previous diff chunk or comment
N / P :next / previous comment
<Up> / <Down> :next / previous line
<Enter> :respond to / edit current comment
d :mark current comment as done
Issue
u :up to list of issues
m :publish + mail comments
j / k :jump to patch after / before current patch
o / <Enter> :open current patch in side-by-side view
i :open current patch in unified diff view
Issue List
j / k :jump to issue after / before current issue
o / <Enter> :open current issue
# : close issue
Comment/message editing
<Ctrl> + s or <Ctrl> + Enter :save comment
<Esc> :cancel edit
Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(14)
Issues Repositories Search
Open Issues | Closed Issues | All Issues | Sign in with your Google Account to create issues and add comments

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

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 6 months ago by haypo_gmail
Modified:
11 years, 6 months ago
Reviewers:
GvR
Visibility:
Public.
Enable debug mode of event loops when PYTHONASYNCIODEBUG is set

Patch Set 1 #

Total comments: 4
Created: 11 years, 6 months ago
Download [raw] [tar.bz2]
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
Total messages: 3
|
GvR
I'm not sure I understand the reason for these changes. Why can't you have the ...
11 years, 6 months ago (2014年06月18日 03:53:36 UTC) #1
I'm not sure I understand the reason for these changes. Why can't you have the
current event loop be None in debug mode? Shouldn't the check-loop code be
smarter rather than having to set the loop only in debug mode?
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
I don't understand this.
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
This seems wrong.
Sign in to reply to this message.
haypo_gmail
On 2014年06月18日 03:53:36, GvR wrote: > I'm not sure I understand the reason for these ...
11 years, 6 months ago (2014年06月18日 09:24:34 UTC) #2
On 2014年06月18日 03:53:36, GvR wrote:
> I'm not sure I understand the reason for these changes. Why can't you have the
> current event loop be None in debug mode?
See my comment.
> Shouldn't the check-loop code be
> smarter rather than having to set the loop only in debug mode?
It's nice to be able to run tests with the event loop of the current policy to
set to None to check that the event loop is passed explicitly in asyncio.
In debug mode, it's not possible to use these checks because the event loop of
the current policy must be None. Otherwise, call_soon() and similar functions
fail (see the traceback in my comment).
Sign in to reply to this message.
haypo_gmail
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#newcode404 asyncio/proactor_events.py:404: # from the event loop constructor On 2014年06月18日 03:53:36, ...
11 years, 6 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

AltStyle によって変換されたページ (->オリジナル) /