FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-client/splitio/util/threadutil.py at development · splitio/python-client · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
splitio
/
python-client
Public
Notifications
You must be signed in to change notification settings
Fork
13
Star
19
Code
Issues
4
Pull requests
5
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-client
/
splitio
/
util
/
threadutil.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
51 lines (39 loc) · 1.48 KB
Breadcrumbs
python-client
/
splitio
/
util
/
threadutil.py
Copy path
File metadata and controls
51 lines (39 loc) · 1.48 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""Threading utilities."""
from
threading
import
Event
,
Condition
class
EventGroup
(
object
):
"""EventGroup that can be waited with an OR condition."""
class
Event
(
Event
):
# pylint:disable=too-few-public-methods
"""Threading event meant to be used in an group."""
def
__init__
(
self
,
shared_condition
):
"""
Construct an event.
:param shared_condition: shared condition varaible.
:type shared_condition: threading.Condition
"""
Event
.
__init__
(
self
)
self
.
_shared_cond
=
shared_condition
def
set
(
self
):
"""Set the event."""
Event
.
set
(
self
)
with
self
.
_shared_cond
:
self
.
_shared_cond
.
notify
()
def
__init__
(
self
):
"""Construct an event group."""
self
.
_cond
=
Condition
()
def
make_event
(
self
):
"""
Make a new event associated to this waitable group.
:returns: an event that can be awaited as part of a group
:rtype: EventGroup.Event
"""
return
EventGroup
.
Event
(
self
.
_cond
)
def
wait
(
self
,
timeout
=
None
):
"""
Wait until one of the events is triggered.
:param timeout: how many seconds to wait. None means forever.
:type timeout: int
:returns: True if the condition was notified within the specified timeout. False otherwise.
:rtype: bool
"""
with
self
.
_cond
:
return
self
.
_cond
.
wait
(
timeout
)
Back
|
FazBrowse Home
|
New Git URL