Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gargantext-ihaskell
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
gargantext-ihaskell
Commits
42929121
Unverified
Commit
42929121
authored
Jul 22, 2015
by
Joe Hendrix
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minimize interface to ephemeral ports.
parent
55552c8a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
15 deletions
+20
-15
ZeroMQ.hs
ipython-kernel/src/IHaskell/IPython/ZeroMQ.hs
+20
-15
No files found.
ipython-kernel/src/IHaskell/IPython/ZeroMQ.hs
View file @
42929121
...
@@ -10,7 +10,7 @@ module IHaskell.IPython.ZeroMQ
...
@@ -10,7 +10,7 @@ module IHaskell.IPython.ZeroMQ
,
ZeroMQStdin
(
..
)
,
ZeroMQStdin
(
..
)
,
serveProfile
,
serveProfile
,
serveStdin
,
serveStdin
,
ZeroMQEphemeralPorts
(
..
)
,
ZeroMQEphemeralPorts
,
withEphemeralPorts
,
withEphemeralPorts
)
where
)
where
...
@@ -101,6 +101,8 @@ serveProfile profile debug = do
...
@@ -101,6 +101,8 @@ serveProfile profile debug = do
return
channels
return
channels
-- | Describes ports used when creating an ephemeral ZeroMQ session.
-- Used to generate the ipython JSON config file.
data
ZeroMQEphemeralPorts
data
ZeroMQEphemeralPorts
=
ZeroMQEphemeralPorts
{
ephHbPort
::
!
Port
=
ZeroMQEphemeralPorts
{
ephHbPort
::
!
Port
,
ephControlPort
::
!
Port
,
ephControlPort
::
!
Port
...
@@ -134,9 +136,14 @@ bindLocalEphemeralPort socket = do
...
@@ -134,9 +136,14 @@ bindLocalEphemeralPort socket = do
Just
endpointIndex
->
Just
endpointIndex
->
return
endpointIndex
return
endpointIndex
-- | Start responding on all ZeroMQ channels used to communicate with IPython
-- | @withFork thread main@ runs @thread@ in a separate
-- with ephemerally allocated ports.
-- thread, and kills it when @main@ finishes.
-- Profide the callback with the ports chosen and a ZeroMQInterface.
withFork
::
IO
()
->
(
ThreadId
->
IO
a
)
->
IO
a
withFork
thread
=
bracket
(
forkIO
thread
)
killThread
-- | Run session for communicating with an IPython instance on ephemerally allocated
-- ZMQ4 sockets. The sockets will be closed when the callback returns.
withEphemeralPorts
::
ByteString
withEphemeralPorts
::
ByteString
-- ^ HMAC encryption key
-- ^ HMAC encryption key
->
Bool
->
Bool
...
@@ -166,13 +173,11 @@ withEphemeralPorts key debug callback = do
...
@@ -166,13 +173,11 @@ withEphemeralPorts key debug callback = do
,
ephIOPubPort
=
iopubPort
,
ephIOPubPort
=
iopubPort
,
ephSignatureKey
=
key
,
ephSignatureKey
=
key
}
}
-- Launch actions to listen to communicate between channels and cockets.
-- Launch actions to listen to communicate between channels and cockets.
_
<-
forkIO
$
forever
$
heartbeat
channels
heartbeatSocket
withFork
(
forever
$
heartbeat
channels
heartbeatSocket
)
$
\
_
->
do
_
<-
forkIO
$
forever
$
control
debug
channels
controlportSocket
withFork
(
forever
$
control
debug
channels
controlportSocket
)
$
\
_
->
do
_
<-
forkIO
$
forever
$
shell
debug
channels
shellportSocket
withFork
(
forever
$
shell
debug
channels
shellportSocket
)
$
\
_
->
do
_
<-
forkIO
$
forever
$
checkedIOpub
debug
channels
iopubSocket
withFork
(
forever
$
checkedIOpub
debug
channels
iopubSocket
)
$
\
_
->
do
-- Run callback function; provide it with both ports and channels.
-- Run callback function; provide it with both ports and channels.
callback
ports
channels
callback
ports
channels
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment