Commit be76eb53 authored by Denis Bilenko's avatar Denis Bilenko

thread: add __implements__

parent 3d929998
...@@ -7,7 +7,17 @@ ...@@ -7,7 +7,17 @@
:class:`Greenlet` class. :class:`Greenlet` class.
""" """
__thread = __import__('thread') __implements__ = ['allocate_lock',
'get_ident',
'exit',
'LockType',
'stack_size',
'start_new_thread']
__imports__ = ['error']
__thread__ = __import__('thread')
error = __thread__.error
from gevent.hub import getcurrent, GreenletExit from gevent.hub import getcurrent, GreenletExit
from gevent.greenlet import Greenlet from gevent.greenlet import Greenlet
from gevent.coros import Semaphore as LockType from gevent.coros import Semaphore as LockType
...@@ -32,8 +42,10 @@ def allocate_lock(): ...@@ -32,8 +42,10 @@ def allocate_lock():
def exit(): def exit():
raise GreenletExit raise GreenletExit
if hasattr(__thread, 'stack_size'):
_original_stack_size = __thread.stack_size if hasattr(__thread__, 'stack_size'):
_original_stack_size = __thread__.stack_size
def stack_size(size=None): def stack_size(size=None):
if size is None: if size is None:
return _original_stack_size() return _original_stack_size()
...@@ -42,5 +54,10 @@ if hasattr(__thread, 'stack_size'): ...@@ -42,5 +54,10 @@ if hasattr(__thread, 'stack_size'):
else: else:
pass pass
# not going to decrease stack_size, because otherwise other greenlets in this thread will suffer # not going to decrease stack_size, because otherwise other greenlets in this thread will suffer
else:
__implements__.remove('stack_size')
__all__ = __implements__ + __imports__
# XXX interrupt_main, _local # XXX interrupt_main, _local
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment