Skip to content
Permalink
Browse files

Make `skein.Client` picklable (#169)

Unpickling will only work on the same machine the driver is running on.
This is mostly useful for starting a single temporary client and using
it in child processes via multiprocessing.
  • Loading branch information...
jcrist committed Apr 25, 2019
1 parent a86a127 commit 8e2f754a83d9a71c2322f3a61e3b59634cd94ab5
Showing with 14 additions and 0 deletions.
  1. +3 −0 skein/core.py
  2. +11 −0 skein/test/test_core.py
@@ -369,6 +369,9 @@ def __init__(self, address=None, security=None, keytab=None,
proc.wait()
raise

def __reduce__(self):
return (type(self), (self.address, self.security))

@classmethod
def from_global_driver(self):
"""Connect to the global driver."""
@@ -2,6 +2,7 @@

import datetime
import os
import pickle
import subprocess
import time
import warnings
@@ -276,6 +277,16 @@ def test_client_login_from_keytab(security, not_logged_in):
skein.Client(keytab=KEYTAB_PATH, security=security)


def test_client_picklable(client):
b = pickle.dumps(client)
client2 = pickle.loads(b)
assert client2.address == client.address
assert client2.security == client.security
assert client2._proc is None
# Smoketest
client2.get_applications()


def test_get_nodes(client):
nodes = client.get_nodes()
assert nodes

0 comments on commit 8e2f754

Please sign in to comment.
You can’t perform that action at this time.