Skip to content

Commit a46fe17

Browse files
committed
Add cleanup to nbs
1 parent 4697254 commit a46fe17

2 files changed

Lines changed: 38 additions & 1 deletion

File tree

CP5/active_plugins/cpforeign/bioimage_server.ipynb

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,25 @@
5353
"b"
5454
]
5555
},
56+
{
57+
"cell_type": "code",
58+
"execution_count": null,
59+
"metadata": {},
60+
"outputs": [],
61+
"source": [
62+
"def cleanup(context, socket):\n",
63+
" print(\"destroying existing context\")\n",
64+
" if socket:\n",
65+
" socket.close()\n",
66+
" if context:\n",
67+
" context.term()\n",
68+
" # destroy is more destructive\n",
69+
" # doesn't require sockets closed first\n",
70+
" # may leave them hanging if managed by other threads\n",
71+
" context.destroy()\n",
72+
" print(\"socket closed\", socket.closed, \"context closed\", context.closed)\n"
73+
]
74+
},
5675
{
5776
"cell_type": "code",
5877
"execution_count": null,
@@ -69,6 +88,15 @@
6988
" print(\"Received unkown message\", ack)"
7089
]
7190
},
91+
{
92+
"cell_type": "code",
93+
"execution_count": null,
94+
"metadata": {},
95+
"outputs": [],
96+
"source": [
97+
"#cleanup(context, socket)"
98+
]
99+
},
72100
{
73101
"cell_type": "code",
74102
"execution_count": null,
@@ -544,6 +572,15 @@
544572
"source": [
545573
"# socket.send_string(\"Cancel\")"
546574
]
575+
},
576+
{
577+
"cell_type": "code",
578+
"execution_count": null,
579+
"metadata": {},
580+
"outputs": [],
581+
"source": [
582+
"cleanup(context, socket)"
583+
]
547584
}
548585
],
549586
"metadata": {

CP5/active_plugins/cpforeign/zmq_server.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"metadata": {},
7474
"outputs": [],
7575
"source": [
76-
"cleanup(context, socket)"
76+
"#cleanup(context, socket)"
7777
]
7878
},
7979
{

0 commit comments

Comments
 (0)