Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F7159549
thread.py
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
952 B
Referenced Files
None
Subscribers
None
thread.py
View Options
"""implements standard module 'thread' with greenlets"""
__thread
=
__import__
(
'_thread'
)
from
eventlib.support
import
greenlets
as
greenlet
from
eventlib.api
import
spawn
from
eventlib.coros
import
Semaphore
as
LockType
error
=
__thread
.
error
def
get_ident
(
gr
=
None
):
if
gr
is
None
:
return
id
(
greenlet
.
getcurrent
())
else
:
return
id
(
gr
)
def
start_new_thread
(
function
,
args
=
(),
kwargs
=
{}):
g
=
spawn
(
function
,
*
args
,
**
kwargs
)
return
get_ident
(
g
)
def
allocate_lock
():
return
LockType
(
1
)
def
exit
():
raise
greenlet
.
GreenletExit
if
hasattr
(
__thread
,
'stack_size'
):
def
stack_size
(
size
=
None
):
if
size
is
None
:
return
__thread
.
stack_size
()
if
size
>
__thread
.
stack_size
():
return
__thread
.
stack_size
(
size
)
else
:
pass
# not going to decrease stack_size, because otherwise other greenlets in this thread will suffer
# XXX interrupt_main
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 23, 6:59 AM (1 d, 10 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3408970
Default Alt Text
thread.py (952 B)
Attached To
Mode
rPYEVENTLIB python3-eventlib
Attached
Detach File
Event Timeline
Log In to Comment