0

Is it possible to use ZMQ part of Anaconda for custom messaging between jupyter notebooks somehow? My intention is that if there is a boundled solution why should I write my own comm solution, or install something new :-) I would like to query all available notebooks and if the required one is up and running then I want to send custom, streamed data to that notebok. (Previously I made it with asyncio socket server/client architecture with pure .py scripts).

Unfortunately the messaging documentation does not help me too much.

Thank you in advance!

sm.

spyder
  • 115
  • 2
  • 11

1 Answers1

0

Q : "Is it possible to use ZMQ part of Anaconda for custom messaging between jupyter notebooks somehow?"

Sure.

Option A :
One may extend the jupyter framework to include all your new functionalities in FOSS core

Option B :
One may instantiate one's own ZeroMQ signaling / messaging infrastructure on top of & independent from the jupyter internal signaling / messaging functionalities, and work just with a pure user-level code.

include zmq

my1stContextINSTANCE = zmq.context()                          # The Engine
my1stPublisherSOCKET = my1stContextINSTANCE.socket( zmq.PUB ) #        its Socket
my1stPublisherSOCKET.setsockopt( zmq.LINGER,       0 )        #            configurations
my1stPublisherSOCKET.setsockopt( zmq.SNDBUF, 2000000 )        #            ...
...
my1stPullDataSOCKET  = my1stContextINSTANCE.socket( zmq.PULL )#        its Socket
my1stPullDataSOCKET.setsockopt( zmq.LINGER,        0 )        #            configurations
my1stPullDataSOCKET.setsockopt( zmq.RCVBUF,   100000 )        #            ...

...

while True:
   ...
   my1stPublisherSOCKET.send( "INF: message payload[{0:}]".format( repr( _ ) ) )
   ...
   if ( my1stPullDataSOCKET.poll( 0 ) ) ... ):
       ...

   elseif:
       ...

   else:
       ...

   continue

Reciprocally the same on all the other peer-sides.

The ZeroMQ framework is smart for doing this, either way. You may like to read this & this.

The architecture design & the implementation wisdom & robustness is yours.

user3666197
  • 1
  • 6
  • 50
  • 92
  • 1
    Thank you! It helped! I thought I have to install a messaging infrastructure (a cluster or something) to make it work, but it is "just" an importable library. Great! Merry XMath :-) – spyder Dec 24 '20 at 09:35
  • 1
    Boldog Karácsonyt! @spyder – user3666197 Dec 24 '20 at 12:58