Commit 941dc54b authored by Kirill Smelkov's avatar Kirill Smelkov

X wcfs: threading.Lock -> sync.Mutex

prepares the code to be moved into pyx/nogil, as sync.Mutex - contrary
to threading.Lock - is present also in pyx/nogil world.
parent c7dd2e52
...@@ -43,7 +43,6 @@ from errno import ENOENT, EEXIST ...@@ -43,7 +43,6 @@ from errno import ENOENT, EEXIST
from golang import chan, select, default, func, defer from golang import chan, select, default, func, defer
from golang import sync, context from golang import sync, context
from golang.gcompat import qq from golang.gcompat import qq
import threading
from persistent import Persistent from persistent import Persistent
from ZODB.FileStorage import FileStorage from ZODB.FileStorage import FileStorage
...@@ -92,7 +91,7 @@ class Conn(object): ...@@ -92,7 +91,7 @@ class Conn(object):
# .at Tid # .at Tid
# ._wlink WatchLink watch/receive pins for created mappings # ._wlink WatchLink watch/receive pins for created mappings
# #
# ._filemu threading.Lock # ._filemu sync.Mutex
# ._filetab {} foid -> _File # ._filetab {} foid -> _File
# #
# ._pinWG # ._pinWG
...@@ -133,7 +132,7 @@ def connect(wc, at): # -> Conn ...@@ -133,7 +132,7 @@ def connect(wc, at): # -> Conn
wconn._wc = wc wconn._wc = wc
wconn.at = at wconn.at = at
wconn._wlink = WatchLink(wc) wconn._wlink = WatchLink(wc)
wconn._filemu = threading.Lock() wconn._filemu = sync.Mutex()
wconn._filetab = {} wconn._filetab = {}
pinCtx, wconn._pinCancel = context.with_cancel(context.background()) pinCtx, wconn._pinCancel = context.with_cancel(context.background())
...@@ -414,12 +413,12 @@ class WatchLink(object): ...@@ -414,12 +413,12 @@ class WatchLink(object):
# inv.protocol message IO # inv.protocol message IO
wlink._acceptq = chan() # (stream, msg) server originated messages go here wlink._acceptq = chan() # (stream, msg) server originated messages go here
wlink._rxmu = threading.Lock() wlink._rxmu = sync.Mutex()
wlink._rxtab = {} # stream -> rxq server replies go via here wlink._rxtab = {} # stream -> rxq server replies go via here
wlink._accepted = set() # of stream streams we accepted but did not replied yet wlink._accepted = set() # of stream streams we accepted but did not replied yet
wlink._req_next = 1 # stream ID for next client-originated request XXX -> atomic wlink._req_next = 1 # stream ID for next client-originated request XXX -> atomic
wlink._txmu = threading.Lock() # serializes writes wlink._txmu = sync.Mutex() # serializes writes
wlink._txclosed = False wlink._txclosed = False
serveCtx, wlink._serveCancel = context.with_cancel(context.background()) serveCtx, wlink._serveCancel = context.with_cancel(context.background())
...@@ -714,7 +713,7 @@ class FileH(object): ...@@ -714,7 +713,7 @@ class FileH(object):
# ---- join/run wcfs ---- # ---- join/run wcfs ----
_wcmu = threading.Lock() _wcmu = sync.Mutex()
_wcregistry = {} # mntpt -> WCFS _wcregistry = {} # mntpt -> WCFS
@func(WCFS) @func(WCFS)
......
...@@ -661,6 +661,9 @@ class tFile: ...@@ -661,6 +661,9 @@ class tFile:
# head/watch can receive pin message. Be careful to handle cancellation, # head/watch can receive pin message. Be careful to handle cancellation,
# so that on error in another worker we don't get stuck and the # so that on error in another worker we don't get stuck and the
# error can be propagated to wait and reported. # error can be propagated to wait and reported.
#
# XXX after WatchLink is moved to pyx/nogil, do we still need to do
# here with nogil?
have_read = chan(1) have_read = chan(1)
def _(): def _():
b = read_nogil(blkview[0:1]) b = read_nogil(blkview[0:1])
...@@ -1720,7 +1723,8 @@ class tMapping(object): ...@@ -1720,7 +1723,8 @@ class tMapping(object):
# wcfs.py side, _abort_ontimeout could run and kill WCFS. # wcfs.py side, _abort_ontimeout could run and kill WCFS.
# FIXME also test with GIL locked, since wcfs.py pinner must be itself # FIXME also test with GIL locked, since wcfs.py pinner must be itself
# running without GIL. XXX # running without GIL. XXX
_ = read_nogil(blkview[:1]) #_ = read_nogil(blkview[:1])
_ = blkview[0] # NOTE with gil
assert _ == dataok[0] assert _ == dataok[0]
assert blkview.tobytes() == dataok assert blkview.tobytes() == dataok
......
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