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
8ae3fc37
Commit
8ae3fc37
authored
Jun 17, 2010
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: add 'flags_str' property to event; use it in __str__ and __repr__
parent
bbf94c96
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
4 deletions
+29
-4
gevent/core.pyx
gevent/core.pyx
+29
-4
No files found.
gevent/core.pyx
View file @
8ae3fc37
...
@@ -108,6 +108,14 @@ cdef extern from "libevent.h":
...
@@ -108,6 +108,14 @@ cdef extern from "libevent.h":
int
EV_SIGNAL
int
EV_SIGNAL
int
EV_PERSIST
int
EV_PERSIST
int
EVLIST_TIMEOUT
int
EVLIST_INSERTED
int
EVLIST_SIGNAL
int
EVLIST_ACTIVE
int
EVLIST_INTERNAL
int
EVLIST_INIT
cdef
extern
from
"string.h"
:
cdef
extern
from
"string.h"
:
char
*
strerror
(
int
errnum
)
char
*
strerror
(
int
errnum
)
...
@@ -233,6 +241,23 @@ cdef class event:
...
@@ -233,6 +241,23 @@ cdef class event:
def
__get__
(
self
):
def
__get__
(
self
):
return
self
.
ev
.
ev_flags
return
self
.
ev
.
ev_flags
property
flags_str
:
def
__get__
(
self
):
result
=
[]
cdef
int
flags
=
self
.
ev
.
ev_flags
cdef
int
c_flag
for
(
flag
,
txt
)
in
((
EVLIST_TIMEOUT
,
'TIMEOUT'
),
(
EVLIST_INSERTED
,
'INSERTED'
),
(
EVLIST_SIGNAL
,
'SIGNAL'
),
(
EVLIST_ACTIVE
,
'ACTIVE'
),
(
EVLIST_INTERNAL
,
'INTERNAL'
),
(
EVLIST_INIT
,
'INIT'
)):
c_flag
=
flag
if
flags
&
c_flag
:
result
.
append
(
txt
)
c_flag
=
c_flag
^
0xffffffff
flags
=
flags
&
c_flag
if
flags
:
result
.
append
(
hex
(
flags
))
return
'|'
.
join
(
result
)
def
add
(
self
,
timeout
=-
1
):
def
add
(
self
,
timeout
=-
1
):
"""Add event to be executed after an optional *timeout* - number of seconds
"""Add event to be executed after an optional *timeout* - number of seconds
after which the event will be executed."""
after which the event will be executed."""
...
@@ -274,8 +299,8 @@ cdef class event:
...
@@ -274,8 +299,8 @@ cdef class event:
events_str
=
' %s'
%
self
.
events_str
events_str
=
' %s'
%
self
.
events_str
else
:
else
:
events_str
=
''
events_str
=
''
return
'<%s at %s%s fd=%s%s flags=
0x%x
cb=%s arg=%s>'
%
\
return
'<%s at %s%s fd=%s%s flags=
%s
cb=%s arg=%s>'
%
\
(
type
(
self
).
__name__
,
hex
(
id
(
self
)),
pending
,
self
.
fd
,
events_str
,
self
.
flags
,
self
.
_callback
,
self
.
_arg
)
(
type
(
self
).
__name__
,
hex
(
id
(
self
)),
pending
,
self
.
fd
,
events_str
,
self
.
flags
_str
,
self
.
_callback
,
self
.
_arg
)
def
__str__
(
self
):
def
__str__
(
self
):
if
self
.
pending
:
if
self
.
pending
:
...
@@ -288,8 +313,8 @@ cdef class event:
...
@@ -288,8 +313,8 @@ cdef class event:
events_str
=
''
events_str
=
''
cb
=
str
(
self
.
_callback
).
replace
(
'
\
n
'
,
'
\
n
'
+
' '
*
8
)
cb
=
str
(
self
.
_callback
).
replace
(
'
\
n
'
,
'
\
n
'
+
' '
*
8
)
arg
=
pformat
(
self
.
_arg
,
indent
=
2
).
replace
(
'
\
n
'
,
'
\
n
'
+
' '
*
8
)
arg
=
pformat
(
self
.
_arg
,
indent
=
2
).
replace
(
'
\
n
'
,
'
\
n
'
+
' '
*
8
)
return
'%s%s fd=%s%s flags=
0x%x
\
n
cb = %s
\
n
arg = %s'
%
\
return
'%s%s fd=%s%s flags=
%s
\
n
cb = %s
\
n
arg = %s'
%
\
(
type
(
self
).
__name__
,
pending
,
self
.
fd
,
events_str
,
self
.
flags
,
cb
,
arg
)
(
type
(
self
).
__name__
,
pending
,
self
.
fd
,
events_str
,
self
.
flags
_str
,
cb
,
arg
)
def
__enter__
(
self
):
def
__enter__
(
self
):
return
self
return
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