Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mitogen
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
mitogen
Commits
6905dc4e
Commit
6905dc4e
authored
Feb 15, 2018
by
David Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
master: use queue-like Latch in Select() too.
parent
d13ab9a0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
14 deletions
+12
-14
mitogen/core.py
mitogen/core.py
+9
-8
mitogen/master.py
mitogen/master.py
+3
-6
No files found.
mitogen/core.py
View file @
6905dc4e
...
...
@@ -78,7 +78,7 @@ else:
class
Error
(
Exception
):
def
__init__
(
self
,
fmt
,
*
args
):
def
__init__
(
self
,
fmt
=
None
,
*
args
):
if
args
:
fmt
%=
args
Exception
.
__init__
(
self
,
fmt
)
...
...
@@ -113,7 +113,7 @@ class StreamError(Error):
pass
class
TimeoutError
(
Stream
Error
):
class
TimeoutError
(
Error
):
pass
...
...
@@ -805,24 +805,25 @@ class Latch(object):
if
self
.
queue
:
return
self
.
queue
.
pop
(
0
)
if
not
block
:
r
eturn
r
aise
TimeoutError
()
self
.
_tls_init
()
self
.
wake_socks
.
append
(
_tls
.
wsock
)
finally
:
self
.
lock
.
release
()
rfds
,
_
,
_
=
select
.
select
([
_tls
.
rsock
],
[],
[],
timeout
)
assert
len
(
rfds
)
or
timeout
is
None
assert
len
(
rfds
)
or
timeout
is
not
None
self
.
lock
.
acquire
()
try
:
if
_tls
.
wsock
in
self
.
wake_socks
:
# Nothing woke us, remove stale entry.
self
.
wake_socks
.
remove
(
_tls
.
wsock
)
return
if
_tls
.
rsock
in
rfds
:
_tls
.
rsock
.
recv
(
1
)
return
self
.
queue
.
pop
(
0
)
raise
TimeoutError
()
assert
_tls
.
rsock
in
rfds
_tls
.
rsock
.
recv
(
1
)
return
self
.
queue
.
pop
(
0
)
finally
:
self
.
lock
.
release
()
...
...
mitogen/master.py
View file @
6905dc4e
...
...
@@ -126,14 +126,12 @@ class Select(object):
def
__init__
(
self
,
receivers
=
(),
oneshot
=
True
):
self
.
_receivers
=
[]
self
.
_oneshot
=
oneshot
self
.
_queue
=
Queue
.
Queue
()
self
.
_latch
=
mitogen
.
core
.
Latch
()
for
recv
in
receivers
:
self
.
add
(
recv
)
def
_put
(
self
,
value
):
self
.
_queue
.
put
(
value
)
self
.
_latch
.
wake
()
self
.
_latch
.
put
(
value
)
if
self
.
notify
:
self
.
notify
(
self
)
...
...
@@ -193,7 +191,7 @@ class Select(object):
self
.
remove
(
recv
)
def
empty
(
self
):
return
self
.
_
queue
.
empty
()
return
self
.
_
latch
.
empty
()
empty_msg
=
'Cannot get(), Select instance is empty'
...
...
@@ -202,8 +200,7 @@ class Select(object):
raise
SelectError
(
self
.
empty_msg
)
while
True
:
self
.
_latch
.
wait
()
recv
=
self
.
_queue
.
get
()
recv
=
self
.
_latch
.
get
(
timeout
=
timeout
)
try
:
msg
=
recv
.
get
(
block
=
False
)
if
self
.
_oneshot
:
...
...
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