Skip to content

Commit 5a53403

Browse files
committed
close
1 parent c127247 commit 5a53403

File tree

3 files changed

+40
-34
lines changed

3 files changed

+40
-34
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
- Added nREPL Server support.
6+
- Dropped Python 3.8 support and added 3.13 in CI testing.
7+
- Set minimum Basilisp version to >=0.3.2.
8+
59
## 1.1.0
610

711
- Optimized output to stdout/stderr by removing proxy string intermediary.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Start your Jupyter notebook server:
3939
jupyter notebook
4040
```
4141

42-
In the Jupyter interface, select the Basilisp kernel when creating a new notebook.
42+
In the Jupyter interface, select the `Basilisp` Kernel when creating a new notebook.
4343

4444
## Examples
4545

@@ -58,7 +58,7 @@ The Basilisp Kernel includes an nREPL server, allowing remote interaction with n
5858
Start the nREPL in your notebook by running:
5959
```clojure
6060
(require '[basilisp-kernel.nrepl-server :refer [server-start server-shut]])
61-
(def server (server-start {}))
61+
(def server (server-start))
6262
=> nREPL server started on port 58966 on host 127.0.0.1 - nrepl://127.0.0.1:58966
6363
=> #'user/server
6464
```
@@ -72,9 +72,9 @@ For additional configuration options, such as specifying a port with `:port` or
7272
=> :shut
7373
```
7474

75-
## Getting started with Basilisp Notebooks
75+
## Getting Started with Basilisp Notebooks Development
7676

77-
Below are various methods to help you start writing Basilisp code that can be loaded in a Notebook.
77+
Below are various methods to help you start writing Basilisp code that can be loaded in a Basilisp notebook.
7878

7979
### 🔋 Batteries Included Project: `basilex-notebook`
8080

basilisp_kernel/nrepl_server.lpy

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"Starts the nrepl-server in async mode according to `OPTS`, using a
2727
asyncio task to schedule any pending client work every 100ms.
2828

29-
`OPTS` is a map that can have the following keys
29+
`OPTS` is a map that can have the following keys. It defaults to {}.
3030

3131
`:dir` The directory where the `.nrepl-port` file should be created
3232
at. It defaults to the current working directory if not given or
@@ -49,38 +49,40 @@
4949
connections.
5050

5151
`:shutdown!` A function to shutdown the server."
52-
[{:keys [host port dir interval-sec] :as opts
53-
:or {port 0
54-
interval-sec 0.1}}]
55-
(let [host (if (or (nil? host) (empty? (str/trim host)))
56-
"127.0.0.1"
57-
host)
58-
nrepl-port-dir (if (or (nil? dir) (empty? (str/trim dir)))
59-
"."
60-
dir)]
52+
([]
53+
(server-start {}))
54+
([{:keys [host port dir interval-sec] :as opts
55+
:or {port 0
56+
interval-sec 0.1}}]
57+
(let [host (if (or (nil? host) (empty? (str/trim host)))
58+
"127.0.0.1"
59+
host)
60+
nrepl-port-dir (if (or (nil? dir) (empty? (str/trim dir)))
61+
"."
62+
dir)]
6163

62-
(if (not (os.path/isdir nrepl-port-dir))
63-
{:error (u/error-make [:nrepl-server-start :nrepl-port-dir-not-a-dir nrepl-port-dir])}
64+
(if (not (os.path/isdir nrepl-port-dir))
65+
{:error (u/error-make [:nrepl-server-start :nrepl-port-dir-not-a-dir nrepl-port-dir])}
6466

65-
(let [{:keys [error work-fn shutdown-fn] :as ret}
66-
(nr/server-start! {:async? true
67-
:host host
68-
:port port
69-
:nrepl-port-file (os.path/join nrepl-port-dir ".nrepl-port")})]
70-
(if error
71-
(binding [*out* sys/stderr]
72-
(println :server-start-error (u/error->str error))
73-
{:error error})
67+
(let [{:keys [error work-fn shutdown-fn] :as ret}
68+
(nr/server-start! {:async? true
69+
:host host
70+
:port port
71+
:nrepl-port-file (os.path/join nrepl-port-dir ".nrepl-port")})]
72+
(if error
73+
(binding [*out* sys/stderr]
74+
(println :server-start-error (u/error->str error))
75+
{:error error})
7476

75-
(let [shutdown?* (volatile! false)
76-
shutdown! #(do (vreset! shutdown?* true)
77-
(shutdown-fn)
78-
:shut)
79-
loop (asyncio/get-running-loop)
80-
task (.create-task loop (work-task interval-sec work-fn shutdown?* shutdown!))]
81-
(-> (select-keys ret [:host :port :nrepl-port-file])
82-
(assoc :shutdown! shutdown!
83-
:_task task))))))))
77+
(let [shutdown?* (volatile! false)
78+
shutdown! #(do (vreset! shutdown?* true)
79+
(shutdown-fn)
80+
:shut)
81+
loop (asyncio/get-running-loop)
82+
task (.create-task loop (work-task interval-sec work-fn shutdown?* shutdown!))]
83+
(-> (select-keys ret [:host :port :nrepl-port-file])
84+
(assoc :shutdown! shutdown!
85+
:_task task)))))))))
8486

8587
(defn ^:inline server-shut
8688
"Convenience function to shutdown the `SERVER`."

0 commit comments

Comments
 (0)