Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
d5ea5d52
Commit
d5ea5d52
authored
Dec 04, 2014
by
Victor Stinner
Browse files
Options
Browse Files
Download
Plain Diff
Merge 3.4 (asyncio)
parents
74aee426
e80bf0d4
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
6 deletions
+44
-6
Lib/asyncio/base_events.py
Lib/asyncio/base_events.py
+4
-0
Lib/asyncio/futures.py
Lib/asyncio/futures.py
+1
-2
Lib/asyncio/tasks.py
Lib/asyncio/tasks.py
+4
-3
Lib/asyncio/unix_events.py
Lib/asyncio/unix_events.py
+1
-0
Lib/test/test_asyncio/test_events.py
Lib/test/test_asyncio/test_events.py
+34
-1
No files found.
Lib/asyncio/base_events.py
View file @
d5ea5d52
...
...
@@ -177,6 +177,7 @@ class BaseEventLoop(events.AbstractEventLoop):
Return a task object.
"""
self
.
_check_closed
()
task
=
tasks
.
Task
(
coro
,
loop
=
self
)
if
task
.
_source_traceback
:
del
task
.
_source_traceback
[
-
1
]
...
...
@@ -360,6 +361,7 @@ class BaseEventLoop(events.AbstractEventLoop):
if
(
coroutines
.
iscoroutine
(
callback
)
or
coroutines
.
iscoroutinefunction
(
callback
)):
raise
TypeError
(
"coroutines cannot be used with call_at()"
)
self
.
_check_closed
()
if
self
.
_debug
:
self
.
_assert_is_current_event_loop
()
timer
=
events
.
TimerHandle
(
when
,
callback
,
args
,
self
)
...
...
@@ -390,6 +392,7 @@ class BaseEventLoop(events.AbstractEventLoop):
raise
TypeError
(
"coroutines cannot be used with call_soon()"
)
if
self
.
_debug
and
check_loop
:
self
.
_assert_is_current_event_loop
()
self
.
_check_closed
()
handle
=
events
.
Handle
(
callback
,
args
,
self
)
if
handle
.
_source_traceback
:
del
handle
.
_source_traceback
[
-
1
]
...
...
@@ -426,6 +429,7 @@ class BaseEventLoop(events.AbstractEventLoop):
if
(
coroutines
.
iscoroutine
(
callback
)
or
coroutines
.
iscoroutinefunction
(
callback
)):
raise
TypeError
(
"coroutines cannot be used with run_in_executor()"
)
self
.
_check_closed
()
if
isinstance
(
callback
,
events
.
Handle
):
assert
not
args
assert
not
isinstance
(
callback
,
events
.
TimerHandle
)
...
...
Lib/asyncio/futures.py
View file @
d5ea5d52
...
...
@@ -135,6 +135,7 @@ class Future:
_result
=
None
_exception
=
None
_loop
=
None
_source_traceback
=
None
_blocking
=
False
# proper use of future (yield vs yield from)
...
...
@@ -155,8 +156,6 @@ class Future:
self
.
_callbacks
=
[]
if
self
.
_loop
.
get_debug
():
self
.
_source_traceback
=
traceback
.
extract_stack
(
sys
.
_getframe
(
1
))
else
:
self
.
_source_traceback
=
None
def
_format_callbacks
(
self
):
cb
=
self
.
_callbacks
...
...
Lib/asyncio/tasks.py
View file @
d5ea5d52
...
...
@@ -41,6 +41,10 @@ class Task(futures.Future):
# all running event loops. {EventLoop: Task}
_current_tasks
=
{}
# If False, don't log a message if the task is destroyed whereas its
# status is still pending
_log_destroy_pending
=
True
@
classmethod
def
current_task
(
cls
,
loop
=
None
):
"""Return the currently running task in an event loop or None.
...
...
@@ -73,9 +77,6 @@ class Task(futures.Future):
self
.
_must_cancel
=
False
self
.
_loop
.
call_soon
(
self
.
_step
)
self
.
__class__
.
_all_tasks
.
add
(
self
)
# If False, don't log a message if the task is destroyed whereas its
# status is still pending
self
.
_log_destroy_pending
=
True
# On Python 3.3 or older, objects with a destructor that are part of a
# reference cycle are never destroyed. That's not the case any more on
...
...
Lib/asyncio/unix_events.py
View file @
d5ea5d52
...
...
@@ -71,6 +71,7 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop):
or
coroutines
.
iscoroutinefunction
(
callback
)):
raise
TypeError
(
"coroutines cannot be used with add_signal_handler()"
)
self
.
_check_signal
(
sig
)
self
.
_check_closed
()
try
:
# set_wakeup_fd() raises ValueError if this is not the
# main thread. By calling it early we ensure that an
...
...
Lib/test/test_asyncio/test_events.py
View file @
d5ea5d52
...
...
@@ -226,7 +226,8 @@ class EventLoopTestsMixin:
def
tearDown
(
self
):
# just in case if we have transport close callbacks
test_utils
.
run_briefly
(
self
.
loop
)
if
not
self
.
loop
.
is_closed
():
test_utils
.
run_briefly
(
self
.
loop
)
self
.
loop
.
close
()
gc
.
collect
()
...
...
@@ -1434,6 +1435,38 @@ class EventLoopTestsMixin:
with
self
.
assertRaises
(
RuntimeError
):
self
.
loop
.
run_until_complete
(
coro
)
def
test_close
(
self
):
self
.
loop
.
close
()
@
asyncio
.
coroutine
def
test
():
pass
func
=
lambda
:
False
coro
=
test
()
self
.
addCleanup
(
coro
.
close
)
# operation blocked when the loop is closed
with
self
.
assertRaises
(
RuntimeError
):
self
.
loop
.
run_forever
()
with
self
.
assertRaises
(
RuntimeError
):
fut
=
asyncio
.
Future
(
loop
=
self
.
loop
)
self
.
loop
.
run_until_complete
(
fut
)
with
self
.
assertRaises
(
RuntimeError
):
self
.
loop
.
call_soon
(
func
)
with
self
.
assertRaises
(
RuntimeError
):
self
.
loop
.
call_soon_threadsafe
(
func
)
with
self
.
assertRaises
(
RuntimeError
):
self
.
loop
.
call_later
(
1.0
,
func
)
with
self
.
assertRaises
(
RuntimeError
):
self
.
loop
.
call_at
(
self
.
loop
.
time
()
+
.
0
,
func
)
with
self
.
assertRaises
(
RuntimeError
):
self
.
loop
.
run_in_executor
(
None
,
func
)
with
self
.
assertRaises
(
RuntimeError
):
self
.
loop
.
create_task
(
coro
)
with
self
.
assertRaises
(
RuntimeError
):
self
.
loop
.
add_signal_handler
(
signal
.
SIGTERM
,
func
)
class
SubprocessTestsMixin
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment