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
eedd8eda
Commit
eedd8eda
authored
Apr 14, 2016
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test__core works for libev
parent
0c828704
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
61 additions
and
20 deletions
+61
-20
src/gevent/_ffi/watcher.py
src/gevent/_ffi/watcher.py
+14
-0
src/gevent/libev/corecffi.py
src/gevent/libev/corecffi.py
+2
-5
src/gevent/libev/watcher.py
src/gevent/libev/watcher.py
+3
-13
src/gevent/libuv/_corecffi_cdef.c
src/gevent/libuv/_corecffi_cdef.c
+4
-0
src/gevent/libuv/loop.py
src/gevent/libuv/loop.py
+21
-0
src/gevent/libuv/watcher.py
src/gevent/libuv/watcher.py
+6
-0
src/greentest/test__core.py
src/greentest/test__core.py
+11
-2
No files found.
src/gevent/_ffi/watcher.py
View file @
eedd8eda
...
...
@@ -17,6 +17,20 @@ __all__ = [
]
def
events_to_str
(
event_field
,
all_events
):
result
=
[]
for
(
flag
,
string
)
in
all_events
:
c_flag
=
flag
if
event_field
&
c_flag
:
result
.
append
(
string
)
event_field
=
event_field
&
(
~
c_flag
)
if
not
event_field
:
break
if
event_field
:
result
.
append
(
hex
(
event_field
))
return
'|'
.
join
(
result
)
def
not_while_active
(
func
):
@
functools
.
wraps
(
func
)
def
nw
(
self
,
*
args
,
**
kwargs
):
...
...
src/gevent/libev/corecffi.py
View file @
eedd8eda
...
...
@@ -80,11 +80,8 @@ SIGNALFD = libev.EVFLAG_SIGNALFD
NOSIGMASK
=
libev
.
EVFLAG_NOSIGMASK
class
_EVENTSType
(
object
):
def
__repr__
(
self
):
return
'gevent.core.EVENTS'
EVENTS
=
GEVENT_CORE_EVENTS
=
_EVENTSType
()
from
gevent._ffi.loop
import
EVENTS
GEVENT_CORE_EVENTS
=
EVENTS
def
get_version
():
...
...
src/gevent/libev/watcher.py
View file @
eedd8eda
...
...
@@ -46,21 +46,11 @@ _events = [(libev.EV_READ, 'READ'),
(
libev
.
EV_CUSTOM
,
'CUSTOM'
),
(
libev
.
EV_ERROR
,
'ERROR'
)]
def
_events_to_str
(
events
):
result
=
[]
for
(
flag
,
string
)
in
_events
:
c_flag
=
flag
if
events
&
c_flag
:
result
.
append
(
string
)
events
=
events
&
(
~
c_flag
)
if
not
events
:
break
if
events
:
result
.
append
(
hex
(
events
))
return
'|'
.
join
(
result
)
from
gevent._ffi
import
watcher
as
_base
def
_events_to_str
(
events
):
return
_base
.
events_to_str
(
events
,
_events
)
from
gevent._ffi
import
watcher
as
_base
class
watcher
(
_base
.
watcher
):
...
...
src/gevent/libuv/_corecffi_cdef.c
View file @
eedd8eda
...
...
@@ -5,6 +5,9 @@
#define UV_EBUSY ...
#define UV_VERSION_MAJOR ...
#define UV_VERSION_MINOR ...
#define UV_VERSION_PATCH ...
typedef
enum
{
UV_RUN_DEFAULT
=
0
,
...
...
@@ -52,6 +55,7 @@ enum uv_fs_event_flags {
const
char
*
uv_strerror
(
int
);
const
char
*
uv_err_name
(
int
);
const
char
*
uv_version_string
(
void
);
// handle structs and types
struct
uv_loop_s
{
...
...
src/gevent/libuv/loop.py
View file @
eedd8eda
...
...
@@ -22,8 +22,29 @@ __all__ = [
_callbacks
=
assign_standard_callbacks
(
ffi
,
libuv
)
from
gevent._ffi.loop
import
EVENTS
GEVENT_CORE_EVENTS
=
EVENTS
# export
from
gevent.libuv
import
watcher
as
_watchers
_events_to_str
=
_watchers
.
_events_to_str
# export
READ
=
libuv
.
UV_READABLE
WRITE
=
libuv
.
UV_WRITABLE
def
get_version
():
uv_bytes
=
ffi
.
string
(
libuv
.
uv_version_string
())
if
not
isinstance
(
uv_bytes
,
str
):
# Py3
uv_str
=
uv_bytes
.
decode
(
"ascii"
)
else
:
uv_str
=
uv_bytes
return
'libuv-'
+
uv_str
def
get_header_version
():
return
'libuv-%d.%d.%d'
%
(
libuv
.
UV_VERSION_MAJOR
,
libuv
.
UV_VERSION_MINOR
,
libuv
.
UV_VERSION_PATCH
)
class
loop
(
AbstractLoop
):
error_handler
=
None
...
...
src/gevent/libuv/watcher.py
View file @
eedd8eda
...
...
@@ -21,6 +21,12 @@ def _uv_close_callback(handle):
def
_dbg
(
*
args
,
**
kwargs
):
pass
_events
=
[(
libuv
.
UV_READABLE
,
"READ"
),
(
libuv
.
UV_WRITABLE
,
"WRITE"
)]
def
_events_to_str
(
events
):
# export
return
_base
.
events_to_str
(
events
,
_events
)
class
watcher
(
_base
.
watcher
):
_FFI
=
ffi
_LIB
=
libuv
...
...
src/greentest/test__core.py
View file @
eedd8eda
import
sys
from
greentest
import
TestCase
,
main
from
gevent
import
core
import
unittest
class
Test
(
TestCase
):
...
...
@@ -16,6 +17,8 @@ class Test(TestCase):
assert
header_version
,
repr
(
header_version
)
self
.
assertEqual
(
version
,
header_version
)
@
unittest
.
skipIf
(
hasattr
(
core
,
'libuv'
),
"flags are libev-only"
)
def
test_flags_conversion
(
self
):
if
sys
.
platform
!=
'win32'
:
self
.
assertEqual
(
core
.
loop
(
2
,
default
=
False
).
backend_int
,
2
)
...
...
@@ -41,7 +44,9 @@ class Test(TestCase):
Error
=
ValueError
win32
=
False
self
.
assertRaises
(
Error
,
core
.
loop
().
io
,
-
1
,
1
)
self
.
assertRaises
(
ValueError
,
core
.
loop
().
io
,
1
,
core
.
TIMER
)
if
hasattr
(
core
,
'TIMER'
):
# libev
self
.
assertRaises
(
ValueError
,
core
.
loop
().
io
,
1
,
core
.
TIMER
)
# Test we can set events and io before it's started
if
not
win32
:
# We can't do this with arbitrary FDs on windows;
...
...
@@ -50,7 +55,11 @@ class Test(TestCase):
io
.
fd
=
2
self
.
assertEqual
(
io
.
fd
,
2
)
io
.
events
=
core
.
WRITE
self
.
assertEqual
(
core
.
_events_to_str
(
io
.
events
),
'WRITE|_IOFDSET'
)
if
not
hasattr
(
core
,
'libuv'
):
# libev
self
.
assertEqual
(
core
.
_events_to_str
(
io
.
events
),
'WRITE|_IOFDSET'
)
else
:
self
.
assertEqual
(
core
.
_events_to_str
(
io
.
events
),
'WRITE'
)
def
test_timer
(
self
):
self
.
assertRaises
(
ValueError
,
core
.
loop
().
timer
,
1
,
-
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