Skip to content

Commit

Permalink
Consistent argument order.
Browse files Browse the repository at this point in the history
  • Loading branch information
danijar committed Aug 31, 2023
1 parent 392a47c commit c5b26f0
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def donefn(data):
with lock:
done_calls[0] += 1
time.sleep(0.01)
server = Server(addr, workers)
server = Server(addr, workers=workers)
server.bind('function', workfn, donefn)
with server:
client = zerofun.Client(addr, pings=0, maxage=1, connect=True)
Expand Down
2 changes: 1 addition & 1 deletion zerofun/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '1.1.0'
__version__ = '1.2.0'

import multiprocessing as mp
try:
Expand Down
13 changes: 9 additions & 4 deletions zerofun/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@

class Client:

RESOLVERS = []

def __init__(
self, address, identity=None, name='Client', ipv6=False, pings=10,
maxage=120, maxinflight=16, errors=True, connect=False):
self, address, name='Client', ipv6=False, identity=None,
pings=10, maxage=120, maxinflight=16, errors=True,
connect=False):
if identity is None:
identity = int(np.random.randint(2 ** 32))
self.address = address
Expand Down Expand Up @@ -128,8 +131,10 @@ def _listen(self):

@elements.timer.section('client_resolve')
def _resolve(self, address):
protocol, address = address.split('://', 1)
return f'{protocol}://{address}'
for check, resolve in self.RESOLVERS:
if check(address):
return resolve(address)
return address

def _print(self, text):
elements.print(f'[{self.name}] {text}')
Expand Down
4 changes: 2 additions & 2 deletions zerofun/proc_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
class ProcServer:

def __init__(
self, address, workers=1, name='Server', errors=True, ipv6=False):
self, address, name='Server', ipv6=False, workers=1, errors=True):
self.address = address
self.inner = f'ipc:///tmp/inner{np.random.randint(2 ** 32)}'
self.name = name
self.ipv6 = ipv6
self.server = server.Server(self.inner, workers, name, errors, ipv6)
self.server = server.Server(self.inner, name, ipv6, workers, errors)
self.batches = {}
self.batcher = None

Expand Down
2 changes: 1 addition & 1 deletion zerofun/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class Server:

def __init__(
self, address, workers=1, name='Server', errors=True, ipv6=False):
self, address, name='Server', ipv6=False, workers=1, errors=True):
self.address = address
self.workers = workers
self.name = name
Expand Down

0 comments on commit c5b26f0

Please sign in to comment.