Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
a609eaca
Commit
a609eaca
authored
Jan 25, 2018
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update comments about how loops run. [skip ci]
parent
8bbce860
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
6 deletions
+21
-6
src/gevent/_ffi/loop.py
src/gevent/_ffi/loop.py
+9
-2
src/gevent/libuv/loop.py
src/gevent/libuv/loop.py
+12
-4
No files found.
src/gevent/_ffi/loop.py
View file @
a609eaca
...
...
@@ -324,13 +324,17 @@ class AbstractLoop(object):
# self._check is a watcher that runs in each iteration of the
# mainloop, just after the blocking call
# mainloop, just after the blocking call. It's point is to handle
# signals. It doesn't run watchers or callbacks, it just exists to give
# CFFI a chance to raise signal exceptions so we can handle them.
self
.
_check
=
self
.
_ffi
.
new
(
self
.
_CHECK_POINTER
)
self
.
_check
.
data
=
self
.
_handle_to_self
self
.
_init_and_start_check
()
# self._prepare is a watcher that runs in each iteration of the mainloop,
# just before the blocking call
# just before the blocking call. It's where we run deferred callbacks
# from self.run_callback. This cooperates with _setup_for_run_callback()
# to schedule self._timer0 if needed.
self
.
_prepare
=
self
.
_ffi
.
new
(
self
.
_PREPARE_POINTER
)
self
.
_prepare
.
data
=
self
.
_handle_to_self
self
.
_init_and_start_prepare
()
...
...
@@ -589,6 +593,9 @@ class AbstractLoop(object):
raise
NotImplementedError
()
def
run_callback
(
self
,
func
,
*
args
):
# If we happen to already be running callbacks (inside
# _run_callbacks), this could happen almost immediately,
# without the loop cycling.
cb
=
callback
(
func
,
args
)
self
.
_callbacks
.
append
(
cb
)
self
.
_setup_for_run_callback
()
...
...
src/gevent/libuv/loop.py
View file @
a609eaca
...
...
@@ -173,23 +173,31 @@ class loop(AbstractLoop):
# while True:
# uv__update_time(loop);
# uv__run_timers(loop);
# # we don't use pending watchers. They are how libuv
# # implements the pipe/udp/tcp streams.
# ran_pending = uv__run_pending(loop);
# uv__run_idle(loop);
# uv__run_prepare(loop);
# ...
# uv__io_poll(loop, timeout);
# uv__io_poll(loop, timeout);
# <--- IO watchers run here!
# uv__run_check(loop);
# libev looks something like this (pseudo code because the real code is
# hard to read):
#
# do {
# run_fork_callbacks();
# run_prepare_callbacks();
# timeout = min(time of all timers or normal block time)
# io_poll()
# io_poll()
# <--- Only queues IO callbacks
# update_now(); calculate_expired_timers();
# run_timers()
# run_pending()
# run callbacks in this order: (although specificying priorities changes it)
# check
# stat
# child
# signal
# timer
# io
# }
# So instead of running a no-op and letting the side-effect of spinning
...
...
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