@@ -229,6 +229,13 @@ class Client(HasTraits):
229229 The name of the Cluster profile to be used to find connector information.
230230 If run from an IPython application, the default profile will be the same
231231 as the running application, otherwise it will be 'default'.
232+ cluster_id : str
233+ String id to added to runtime files, to prevent name collisions when using
234+ multiple clusters with a single profile simultaneously.
235+ When set, will look for files named like: 'ipcontroller-<cluster_id>-client.json'
236+ Since this is text inserted into filenames, typical recommendations apply:
237+ Simple character strings are ideal, and spaces are not recommended (but
238+ should generally work)
232239 context : zmq.Context
233240 Pass an existing zmq.Context instance, otherwise the client will create its own.
234241 debug : bool
@@ -366,7 +373,7 @@ def __new__(self, *args, **kw):
366373 def __init__ (self , url_file = None , profile = None , profile_dir = None , ipython_dir = None ,
367374 context = None , debug = False ,
368375 sshserver = None , sshkey = None , password = None , paramiko = None ,
369- timeout = 10 , ** extra_args
376+ timeout = 10 , cluster_id = None , ** extra_args
370377 ):
371378 if profile :
372379 super (Client , self ).__init__ (debug = debug , profile = profile )
@@ -388,7 +395,11 @@ def __init__(self, url_file=None, profile=None, profile_dir=None, ipython_dir=No
388395
389396 if self ._cd is not None :
390397 if url_file is None :
391- url_file = pjoin (self ._cd .security_dir , 'ipcontroller-client.json' )
398+ if not cluster_id :
399+ client_json = 'ipcontroller-client.json'
400+ else :
401+ client_json = 'ipcontroller-%s-client.json' % cluster_id
402+ url_file = pjoin (self ._cd .security_dir , client_json )
392403 if url_file is None :
393404 raise ValueError (
394405 "I can't find enough information to connect to a hub!"
0 commit comments