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
5f2c8f44
Commit
5f2c8f44
authored
Apr 13, 2016
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
working on debugging async crash.
parent
69fed3c6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
14 deletions
+22
-14
src/gevent/libuv/_corecffi_source.c
src/gevent/libuv/_corecffi_source.c
+1
-7
src/gevent/libuv/watcher.py
src/gevent/libuv/watcher.py
+21
-7
No files found.
src/gevent/libuv/_corecffi_source.c
View file @
5f2c8f44
...
...
@@ -49,13 +49,7 @@ static void _gevent_fs_event_callback3(void* handle, const char* filename, int e
{
_gevent_generic_callback1
(
handle
,
status
<
0
?
status
:
events
);
}
/*
typedef struct {
uv_fs_poll_t handle;
uv_stat_t curr;
uv_stat_t prev;
} gevent_fs_poll_t;
*/
typedef
struct
_gevent_fs_poll_s
{
uv_fs_poll_t
handle
;
...
...
src/gevent/libuv/watcher.py
View file @
5f2c8f44
...
...
@@ -31,7 +31,7 @@ class watcher(_base.watcher):
# Managing the lifetime of _watcher is tricky.
# They have to be uv_close()'d, but that only
# queues them to be closed in the *next* loop iteration.
# The memory m
o
st stay valid for at least that long,
# The memory m
u
st stay valid for at least that long,
# or assert errors are triggered. We can't use a ffi.gc()
# pointer to queue the uv_close, because by the time the
# destructor is called, there's no way to keep the memory alive
...
...
@@ -39,19 +39,29 @@ class watcher(_base.watcher):
# So here we resort to resurrecting the pointer object out
# of our scope, keeping it alive past this object's lifetime.
# We then use the uv_close callback to handle removing that
# reference. There's no context passed to the clos
s
callback,
# reference. There's no context passed to the clos
e
callback,
# so we have to do this globally.
# Sadly, doing this causes crashes if there were multiple
# watchers for a given FD. See https://github.com/gevent/gevent/issues/790#issuecomment-208076604
# We also have mysterious crashes for async objects.
# see test__pywsgi.py for an example. An async object
# that went out of scope and thus was closed (and had its
# uv_close_callback called) is still in the "queue" of async
# handlers, causing a crash on the next event loop. It's not clear
# how this state can arise.
#print("Del", ffi.cast('void*', self._watcher), 'started', libuv.uv_is_active(self._watcher), type(self), id(self))
if
not
libuv
.
uv_is_closing
(
self
.
_watcher
):
print
(
"Closing handle"
,
self
.
_watcher
)
self
.
_watcher
.
data
=
ffi
.
NULL
#print("Closing handle", self._watcher)
_closing_handles
.
add
(
self
.
_watcher
)
libuv
.
uv_close
(
self
.
_watcher
,
_uv_close_callback
)
self
.
_watcher
=
None
del
self
.
_handle
self
.
_watcher
.
data
=
ffi
.
NULL
del
self
.
_watcher
def
_watcher_ffi_set_priority
(
self
,
priority
):
# libuv has no concept of priority
...
...
@@ -265,11 +275,13 @@ class child(_base.ChildMixin, watcher):
self
.
_rstatus
=
status
self
.
_async
.
send
()
class
async
(
_base
.
AsyncMixin
,
watcher
):
def
_watcher_ffi_init
(
self
,
args
):
pass
# It's dangerous to have a raw, non-initted struct
# around; it will crash in uv_close() when we get GC'd,
# and send() will also crash.
self
.
_watcher_ffi_stop
()
def
_watcher_ffi_start
(
self
):
self
.
_watcher_init
(
self
.
loop
.
ptr
,
self
.
_watcher
,
self
.
_watcher_callback
)
...
...
@@ -278,6 +290,8 @@ class async(_base.AsyncMixin, watcher):
self
.
_watcher_init
(
self
.
loop
.
ptr
,
self
.
_watcher
,
ffi
.
NULL
)
def
send
(
self
):
if
libuv
.
uv_is_closing
(
self
.
_watcher
):
raise
Exception
(
"Closing handle"
)
libuv
.
uv_async_send
(
self
.
_watcher
)
@
property
...
...
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