Commit a0714b8e authored by Kirill Smelkov's avatar Kirill Smelkov

golang_test.pyx: Rename moved channel utilities * -> py*

For consistency to denote that this functions work at Python level:

    - len_sendq    -> pylen_sendq
    - len_recvq    -> pylen_recvq
    - waitBlocked  -> pywaitBlocked
parent a508be9a
......@@ -33,20 +33,20 @@ from golang import time
from golang._golang import _pychan_recv, _pychan_send
from golang._pycompat import im_class
# len_{recv,send}q returns len(ch._{recv,send}q)
def len_recvq(ch):
# pylen_{recv,send}q returns len(ch._{recv,send}q)
def pylen_recvq(ch):
if ch is nilchan:
raise AssertionError('len(.recvq) on nil channel')
return len(ch._recvq)
def len_sendq(ch):
def pylen_sendq(ch):
if ch is nilchan:
raise AssertionError('len(.sendq) on nil channel')
return len(ch._sendq)
# waitBlocked waits till a receive or send channel operation blocks waiting on the channel.
# pywaitBlocked waits till a receive or send channel operation blocks waiting on the channel.
#
# For example `waitBlocked(ch.send)` waits till sender blocks waiting on ch.
def waitBlocked(chanop):
# For example `pywaitBlocked(ch.send)` waits till sender blocks waiting on ch.
def pywaitBlocked(chanop):
if im_class(chanop) is not chan:
pypanic("wait blocked: %r is method of a non-chan: %r" % (chanop, im_class(chanop)))
ch = chanop.__self__
......@@ -61,9 +61,9 @@ def waitBlocked(chanop):
t0 = time.now()
while 1:
with ch._mu:
if recv and len_recvq(ch) > 0:
if recv and pylen_recvq(ch) > 0:
return
if send and len_sendq(ch) > 0:
if send and pylen_sendq(ch) > 0:
return
now = time.now()
if now-t0 > 10: # waited > 10 seconds - likely deadlock
......
......@@ -28,7 +28,8 @@ from subprocess import Popen, PIPE
from six.moves import range as xrange
import gc, weakref
from golang._golang_test import waitBlocked, len_recvq, len_sendq
from golang._golang_test import pywaitBlocked as waitBlocked, pylen_recvq as len_recvq, \
pylen_sendq as len_sendq
# pyx/c/c++ tests -> test_pyx_*
from golang import _golang_test
......
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