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
41c260fa
Commit
41c260fa
authored
Jan 22, 2018
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify the loop definition: always define the _periodic_signal_checker timer member.
parent
f8d6deae
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
21 deletions
+18
-21
CHANGES.rst
CHANGES.rst
+3
-2
src/gevent/libev/callbacks.c
src/gevent/libev/callbacks.c
+1
-2
src/gevent/libev/callbacks.h
src/gevent/libev/callbacks.h
+4
-4
src/gevent/libev/corecext.ppyx
src/gevent/libev/corecext.ppyx
+7
-11
src/gevent/libuv/loop.py
src/gevent/libuv/loop.py
+3
-2
No files found.
CHANGES.rst
View file @
41c260fa
...
...
@@ -162,10 +162,11 @@ libuv
- Using negative timeouts may behave differently from libev.
- libuv blocks delivery of all signals, so signals are handled using
an (arbitrary)
1
second timer. This means that signal handling
an (arbitrary)
0.3
second timer. This means that signal handling
will be delayed by up to that amount, and that the longest the
event loop can sleep in the operating system's ``poll`` call is
that amount.
that amount. Note that this is what gevent does for libev on
Windows too.
- libuv only supports one io watcher per file descriptor, whereas
libev and gevent have always supported many watchers using
...
...
src/gevent/libev/callbacks.c
View file @
41c260fa
...
...
@@ -216,7 +216,7 @@ static void gevent_run_callbacks(struct ev_loop *_loop, void *watcher, int reven
GIL_RELEASE
;
}
#if defined(_WIN32)
/* This is only used on Win32 */
static
void
gevent_periodic_signal_check
(
struct
ev_loop
*
_loop
,
void
*
watcher
,
int
revents
)
{
GIL_DECLARE
;
...
...
@@ -225,6 +225,5 @@ static void gevent_periodic_signal_check(struct ev_loop *_loop, void *watcher, i
GIL_RELEASE
;
}
#endif
/* _WIN32 */
#endif
/* Py_PYTHON_H */
src/gevent/libev/callbacks.h
View file @
41c260fa
...
...
@@ -36,8 +36,8 @@ static void gevent_handle_error(struct PyGeventLoopObject* loop, PyObject* conte
struct
PyGeventCallbackObject
;
static
void
gevent_call
(
struct
PyGeventLoopObject
*
loop
,
struct
PyGeventCallbackObject
*
cb
);
#if defined(_WIN32)
static
void
gevent_periodic_signal_check
(
struct
ev_loop
*
,
void
*
,
int
);
#endif
static
void
gevent_noop
(
struct
ev_loop
*
_loop
,
void
*
watcher
,
int
revents
)
{
}
static
void
gevent_noop
(
struct
ev_loop
*
_loop
,
void
*
watcher
,
int
revents
)
{
}
/* Only used on Win32 */
static
void
gevent_periodic_signal_check
(
struct
ev_loop
*
,
void
*
,
int
);
src/gevent/libev/corecext.ppyx
View file @
41c260fa
...
...
@@ -264,17 +264,16 @@ cdef public class loop [object PyGeventLoopObject, type PyGeventLoop_Type]:
cdef libev.ev_prepare _prepare
cdef public list _callbacks
cdef libev.ev_timer _timer0
#ifdef _WIN32
# We'll only actually start this timer if we're on Windows,
# but it doesn't hurt to compile it in on all platforms.
cdef libev.ev_timer _periodic_signal_checker
#endif
def __init__(self, object flags=None, object default=None, size_t ptr=0):
cdef unsigned int c_flags
cdef object old_handler = None
libev.ev_prepare_init(&self._prepare, <void*>gevent_run_callbacks)
#ifdef _WIN32
libev.ev_timer_init(&self._periodic_signal_checker, <void*>gevent_periodic_signal_check, 0.3, 0.3)
#endif
libev.ev_timer_init(&self._periodic_signal_checker, <void*>gevent_periodic_signal_check,
0.3, 0.3)
libev.ev_timer_init(&self._timer0, <void*>gevent_noop, 0.0, 0.0)
if ptr:
self._ptr = <libev.ev_loop*>ptr
...
...
@@ -291,10 +290,9 @@ cdef public class loop [object PyGeventLoopObject, type PyGeventLoop_Type]:
self._ptr = libev.gevent_ev_default_loop(c_flags)
if not self._ptr:
raise SystemError("ev_default_loop(%s) failed" % (c_flags, ))
#ifdef _WIN32
if sys.platform == "win32":
libev.ev_timer_start(self._ptr, &self._periodic_signal_checker)
libev.ev_unref(self._ptr)
#endif
else:
self._ptr = libev.ev_loop_new(c_flags)
if not self._ptr:
...
...
@@ -324,11 +322,9 @@ cdef public class loop [object PyGeventLoopObject, type PyGeventLoop_Type]:
if libev.ev_is_active(&self._prepare):
libev.ev_ref(self._ptr)
libev.ev_prepare_stop(self._ptr, &self._prepare)
#ifdef _WIN32
if libev.ev_is_active(&self._periodic_signal_checker):
libev.ev_ref(self._ptr)
libev.ev_timer_stop(self._ptr, &self._periodic_signal_checker)
#endif
def destroy(self):
global _default_loop_destroyed
...
...
src/gevent/libuv/loop.py
View file @
41c260fa
...
...
@@ -124,12 +124,13 @@ class loop(AbstractLoop):
# XXX: Perhaps we could optimize this to notice when there are other
# timers in the loop and start/stop it then. When we have a callback
# scheduled, this should also be the same and unnecessary?
# libev does takes this basic approach on Windows.
self
.
_signal_idle
=
ffi
.
new
(
"uv_timer_t*"
)
libuv
.
uv_timer_init
(
self
.
_ptr
,
self
.
_signal_idle
)
self
.
_signal_idle
.
data
=
self
.
_handle_to_self
libuv
.
uv_timer_start
(
self
.
_signal_idle
,
libuv
.
python_check_callback
,
10
00
,
10
00
)
3
00
,
3
00
)
libuv
.
uv_unref
(
self
.
_signal_idle
)
def
_run_callbacks
(
self
):
...
...
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