Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbf4e5d8

Browse files
committed
Fix docstrings for the derived classes needed to get atomic semaphore behaviour in pure-python mode.
Fixes#1639
1 parentaeee4e0 commitbf4e5d8

File tree

4 files changed

+32
-11
lines changed

4 files changed

+32
-11
lines changed

‎.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ before_install:
9292
-if [ -f $BUILD_LIBS/config.cache.ares ]; then cp $BUILD_LIBS/config.cache.ares deps/c-ares/config.cache ; fi
9393
-if [ -f $BUILD_LIBS/config.cache.libev ]; then cp $BUILD_LIBS/config.cache.libev deps/libev/config.cache ; fi
9494
-if [ -f $BUILD_LIBS/config.cache.libuv ]; then cp $BUILD_LIBS/config.cache.libuv deps/libuv/config.cache ; fi
95+
-echo Running in stage $TRAVIS_BUILD_STAGE_NAME
9596
-|
96-
if [[ "$TRAVIS_OS_NAME" == "osx" && "$TRAVIS_BUILD_STAGE_NAME" != "Test" ]]; then
97+
if [[ "$TRAVIS_OS_NAME" == "osx" && "$TRAVIS_BUILD_STAGE_NAME" != "test" ]]; then
9798
brew install ccache
9899
export PATH="/usr/local/opt/ccache/libexec:$PATH"
99100
export CFLAGS="$CFLAGS -Wno-parentheses-equality"

‎docs/api/gevent.lock.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44

55
..automodule::gevent.lock
66
:members:
7+
:inherited-members:

‎src/gevent/lock.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
fromgevent.hubimportgetcurrent
1313
fromgevent._compatimportPURE_PYTHON
14+
fromgevent._compatimportPY2
1415
# This is the one exception to the rule of where to
1516
# import Semaphore, obviously
1617
fromgeventimportmonkey
@@ -128,8 +129,9 @@ class _AtomicSemaphoreMixin(object):
128129
# and re-acquire it for them on exit.
129130
#
130131
# Note that this does *NOT*, in-and-of itself, make semaphores safe to use from multiple threads
132+
__slots__= ()
131133
def__init__(self,*args,**kwargs):
132-
self._lock_lock=_OwnedLock()
134+
self._lock_lock=_OwnedLock()# pylint:disable=assigning-non-slot
133135
super(_AtomicSemaphoreMixin,self).__init__(*args,**kwargs)
134136

135137
def_acquire_lock_for_switch_in(self):
@@ -157,19 +159,45 @@ def wait(self, timeout=None):
157159
returnsuper(_AtomicSemaphoreMixin,self).wait(timeout)
158160

159161
class_AtomicSemaphore(_AtomicSemaphoreMixin,Semaphore):
162+
__doc__=Semaphore.__doc__
160163
__slots__= (
161164
'_lock_lock',
162165
)
163166

167+
164168
class_AtomicBoundedSemaphore(_AtomicSemaphoreMixin,BoundedSemaphore):
169+
__doc__=BoundedSemaphore.__doc__
165170
__slots__= (
166171
'_lock_lock',
167172
)
168173

174+
defrelease(self):# pylint:disable=useless-super-delegation
175+
# This method is duplicated here so that it can get
176+
# properly documented.
177+
returnsuper(_AtomicBoundedSemaphore,self).release()
178+
179+
180+
def_fixup_docstrings():
181+
forcin_AtomicSemaphore,_AtomicBoundedSemaphore:
182+
b=c.__mro__[2]
183+
assertb.__name__.endswith('Semaphore')and'Atomic'notinb.__name__
184+
assertc.__doc__==b.__doc__
185+
formin'acquire','release','wait':
186+
c_meth=getattr(c,m)
187+
ifPY2:
188+
c_meth=c_meth.__func__
189+
b_meth=getattr(b,m)
190+
c_meth.__doc__=b_meth.__doc__
191+
192+
_fixup_docstrings()
193+
del_fixup_docstrings
194+
169195

170196
ifPURE_PYTHON:
171197
Semaphore=_AtomicSemaphore
198+
Semaphore.__name__='Semaphore'
172199
BoundedSemaphore=_AtomicBoundedSemaphore
200+
BoundedSemaphore.__name__='BoundedSemaphore'
173201

174202

175203
classDummySemaphore(object):

‎src/gevent/testing/testrunner.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -718,15 +718,6 @@ def not_set(key):
718718
fork,vinsorted(interesting_envs.items()):
719719
util.log('%*s\t=\t%s',widest_k,k,v,color="debug")
720720

721-
util.run(
722-
[
723-
sys.executable,
724-
'-c',
725-
'from __future__ import print_function; '
726-
'import sys; print("sys.warnoptions:\t", sys.warnoptions)',
727-
],
728-
# Don't log the beginning and end of the subprocess.
729-
quiet=True,nested=True)
730721

731722
defmain():
732723
# pylint:disable=too-many-locals,too-many-statements

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp