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
6315ffa3
Commit
6315ffa3
authored
Jun 20, 2014
by
Charles-François Natali
Browse files
Options
Browse Files
Download
Plain Diff
Merge.
parents
9dca5357
504f5c36
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
64 additions
and
8 deletions
+64
-8
Doc/library/runpy.rst
Doc/library/runpy.rst
+6
-0
Lib/asyncio/base_events.py
Lib/asyncio/base_events.py
+27
-5
Lib/test/test_asyncio/test_base_events.py
Lib/test/test_asyncio/test_base_events.py
+28
-0
Lib/test/test_descr.py
Lib/test/test_descr.py
+1
-1
Lib/test/test_pydoc.py
Lib/test/test_pydoc.py
+1
-1
PCbuild/prepare_ssl.py
PCbuild/prepare_ssl.py
+1
-1
No files found.
Doc/library/runpy.rst
View file @
6315ffa3
...
...
@@ -28,6 +28,9 @@ The :mod:`runpy` module provides two functions:
..
function
::
run_module
(
mod_name
,
init_globals
=
None
,
run_name
=
None
,
alter_sys
=
False
)
..
index
::
module
:
__main__
Execute
the
code
of
the
specified
module
and
return
the
resulting
module
globals
dictionary
.
The
module
's code is first located using the standard
import mechanism (refer to :pep:`302` for details) and then executed in a
...
...
@@ -87,6 +90,9 @@ The :mod:`runpy` module provides two functions:
.. function:: run_path(file_path, init_globals=None, run_name=None)
.. index::
module: __main__
Execute the code at the named filesystem location and return the resulting
module globals dictionary. As with a script name supplied to the CPython
command line, the supplied path may refer to a Python source file, a
...
...
Lib/asyncio/base_events.py
View file @
6315ffa3
...
...
@@ -17,6 +17,7 @@ to modify the meaning of the API call itself.
import
collections
import
concurrent.futures
import
heapq
import
inspect
import
logging
import
socket
import
subprocess
...
...
@@ -37,6 +38,15 @@ __all__ = ['BaseEventLoop', 'Server']
_MAX_WORKERS
=
5
def
_format_handle
(
handle
):
cb
=
handle
.
_callback
if
inspect
.
ismethod
(
cb
)
and
isinstance
(
cb
.
__self__
,
tasks
.
Task
):
# format the task
return
repr
(
cb
.
__self__
)
else
:
return
str
(
handle
)
class
_StopError
(
BaseException
):
"""Raised to stop the event loop."""
...
...
@@ -128,6 +138,9 @@ class BaseEventLoop(events.AbstractEventLoop):
self
.
_clock_resolution
=
time
.
get_clock_info
(
'monotonic'
).
resolution
self
.
_exception_handler
=
None
self
.
_debug
=
False
# In debug mode, if the execution of a callback or a step of a task
# exceed this duration in seconds, the slow callback/task is logged.
self
.
slow_callback_duration
=
0.1
def
__repr__
(
self
):
return
(
'<%s running=%s closed=%s debug=%s>'
...
...
@@ -823,16 +836,16 @@ class BaseEventLoop(events.AbstractEventLoop):
if
logger
.
isEnabledFor
(
logging
.
INFO
):
t0
=
self
.
time
()
event_list
=
self
.
_selector
.
select
(
timeout
)
t1
=
self
.
time
()
if
t1
-
t0
>=
1
:
dt
=
self
.
time
()
-
t0
if
dt
>=
1
:
level
=
logging
.
INFO
else
:
level
=
logging
.
DEBUG
if
timeout
is
not
None
:
logger
.
log
(
level
,
'poll %.3f took %.3f seconds'
,
timeout
,
t1
-
t0
)
timeout
,
dt
)
else
:
logger
.
log
(
level
,
'poll took %.3f seconds'
,
t1
-
t0
)
logger
.
log
(
level
,
'poll took %.3f seconds'
,
dt
)
else
:
event_list
=
self
.
_selector
.
select
(
timeout
)
self
.
_process_events
(
event_list
)
...
...
@@ -855,7 +868,16 @@ class BaseEventLoop(events.AbstractEventLoop):
ntodo
=
len
(
self
.
_ready
)
for
i
in
range
(
ntodo
):
handle
=
self
.
_ready
.
popleft
()
if
not
handle
.
_cancelled
:
if
handle
.
_cancelled
:
continue
if
self
.
_debug
:
t0
=
self
.
time
()
handle
.
_run
()
dt
=
self
.
time
()
-
t0
if
dt
>=
self
.
slow_callback_duration
:
logger
.
warning
(
'Executing %s took %.3f seconds'
,
_format_handle
(
handle
),
dt
)
else
:
handle
.
_run
()
handle
=
None
# Needed to break cycles when an exception occurs.
...
...
Lib/test/test_asyncio/test_base_events.py
View file @
6315ffa3
...
...
@@ -969,6 +969,34 @@ class BaseEventLoopWithSelectorTests(test_utils.TestCase):
with
self
.
assertRaises
(
TypeError
):
self
.
loop
.
run_in_executor
(
None
,
coroutine_function
)
@
mock
.
patch
(
'asyncio.base_events.logger'
)
def
test_log_slow_callbacks
(
self
,
m_logger
):
def
stop_loop_cb
(
loop
):
loop
.
stop
()
@
asyncio
.
coroutine
def
stop_loop_coro
(
loop
):
yield
from
()
loop
.
stop
()
asyncio
.
set_event_loop
(
self
.
loop
)
self
.
loop
.
set_debug
(
True
)
self
.
loop
.
slow_callback_duration
=
0.0
# slow callback
self
.
loop
.
call_soon
(
stop_loop_cb
,
self
.
loop
)
self
.
loop
.
run_forever
()
fmt
,
*
args
=
m_logger
.
warning
.
call_args
[
0
]
self
.
assertRegex
(
fmt
%
tuple
(
args
),
"^Executing Handle.*stop_loop_cb.* took .* seconds$"
)
# slow task
asyncio
.
async
(
stop_loop_coro
(
self
.
loop
),
loop
=
self
.
loop
)
self
.
loop
.
run_forever
()
fmt
,
*
args
=
m_logger
.
warning
.
call_args
[
0
]
self
.
assertRegex
(
fmt
%
tuple
(
args
),
"^Executing Task.*stop_loop_coro.* took .* seconds$"
)
if
__name__
==
'__main__'
:
unittest
.
main
()
Lib/test/test_descr.py
View file @
6315ffa3
...
...
@@ -1149,7 +1149,7 @@ order (MRO) for bases """
except
(
TypeError
,
UnicodeEncodeError
):
pass
else
:
raise
TestFailed
(
"[chr(128)] slots not caught"
)
self
.
fail
(
"[chr(128)] slots not caught"
)
# Test leaks
class
Counted
(
object
):
...
...
Lib/test/test_pydoc.py
View file @
6315ffa3
...
...
@@ -746,7 +746,7 @@ class TestDescriptions(unittest.TestCase):
try
:
pydoc
.
render_doc
(
name
)
except
ImportError
:
self
.
fail
(
'finding the doc of {!r} failed'
.
format
(
o
))
self
.
fail
(
'finding the doc of {!r} failed'
.
format
(
name
))
for
name
in
(
'notbuiltins'
,
'strrr'
,
'strr.translate'
,
'str.trrrranslate'
,
'builtins.strrr'
,
...
...
PCbuild/prepare_ssl.py
View file @
6315ffa3
...
...
@@ -186,7 +186,7 @@ def main():
ssl_dir = sys.argv[1]
if not os.path.
exists(ssl_dir) and os.path.
isdir(ssl_dir):
if not os.path.isdir(ssl_dir):
print(ssl_dir, "
is
not
an
existing
directory
!
")
sys.exit(1)
...
...
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