@@ -110,15 +110,17 @@ to the stream specified in WITH-PYTHON-*-OUTPUT "
110
110
; ; This is "START" in the sense that we start reading now.
111
111
; ; If the thunk has not finished executing and not flushed,
112
112
; ; then LISTEN will return NIL, and this will end
113
- (bt :wait-on-semaphore with-python-start-semaphore)
113
+ (without-python-gil
114
+ (bt :wait-on-semaphore with-python-start-semaphore))
114
115
(loop :while (listen py-stream)
115
116
:do (let ((char (read-char-no-hang py-stream nil )))
116
117
(when char
117
118
(write-char char with-python-stream))))
118
119
; ; Signal the WITH-PYTHON-*-OUTPUT to continue
119
120
(bt :signal-semaphore with-python-end-semaphore)
120
- (bt :with-recursive-lock-held (with-python-count-lock)
121
- (decf in-with-python-count))
121
+ (without-python-gil
122
+ (bt :with-recursive-lock-held (with-python-count-lock)
123
+ (decf in-with-python-count)))
122
124
:else
123
125
:do ; ; PEEK-CHAR waits for input
124
126
(peek-char nil py-stream nil )
@@ -144,13 +146,15 @@ execution of THUNK as a string."
144
146
(unwind-protect
145
147
(progn
146
148
(setf with-python-stream (make-string-output-stream ))
147
- (bt :with-recursive-lock-held (with-python-count-lock)
148
- (incf in-with-python-count))
149
+ (without-python-gil
150
+ (bt :with-recursive-lock-held (with-python-count-lock)
151
+ (incf in-with-python-count)))
149
152
(pycall (format nil " sys.~A .write" stderr-or-stdout) " ." )
150
153
(funcall thunk)
151
154
(pycall (format nil " sys.~A .flush" stderr-or-stdout))
152
155
(bt :signal-semaphore with-python-start-semaphore)
153
- (bt :wait-on-semaphore with-python-end-semaphore)
156
+ (without-python-gil
157
+ (bt :wait-on-semaphore with-python-end-semaphore))
154
158
(setq all-signalled-p t )
155
159
(let* ((output (get-output-stream-string with-python-stream))
156
160
(len (length output)))
@@ -160,7 +164,8 @@ execution of THUNK as a string."
160
164
(progn
161
165
(unless all-signalled-p
162
166
(bt :signal-semaphore with-python-start-semaphore)
163
- (bt :wait-on-semaphore with-python-end-semaphore))
167
+ (without-python-gil
168
+ (bt :wait-on-semaphore with-python-end-semaphore)))
164
169
(setf with-python-stream old-with-python-stream-value))))))
165
170
166
171
; ;; This is more of a global variable than a dynamic variable.
@@ -371,36 +376,6 @@ from inside PYTHON-MAY-BE-ERROR does not lead to an infinite recursion.")
371
376
` (error ' pyerror))
372
377
, pointer)))
373
378
374
- #+ ccl
375
- (defun raw-py (cmd-char &rest code-strings)
376
- " CMD-CHAR should be #\e for eval and #\x for exec.
377
-
378
- Unlike PY4CL or PY4CL2, the use of RAW-PY, RAW-PYEVAL and RAW-PYEXEC,
379
- PYEVAL, PYEXEC should be avoided unless necessary.
380
- Instead, use PYCALL, PYVALUE, (SETF PYVALUE), PYSLOT-VALUE, (SETF PYSLOT-VALUE), and PYMETHOD.
381
-
382
- RAW-PY, RAW-PYEVAL, RAW-PYEXEC are only provided for backward compatibility."
383
- (python-start-if-not-alive)
384
- (unless (zerop (pyforeign-funcall " PyRun_SimpleString"
385
- :string (apply #' concatenate
386
- ' string
387
- (ecase cmd-char
388
- (#\e " _ = " )
389
- (#\x " " ))
390
- code-strings)
391
- :int ))
392
- (error ' pyerror
393
- :format-control " An unknown python error occurred.
394
- Unfortunately, no more information about the error can be provided
395
- while using RAW-PYEVAL or RAW-PYEXEC on ~A "
396
- :format-arguments (lisp-implementation-version )))
397
- (ecase cmd-char
398
- (#\e (let ((ptr (pyvalue* " _" )))
399
- (pyforeign-funcall " Py_IncRef" :pointer ptr)
400
- (pytrack ptr)))
401
- (#\x (values ))))
402
-
403
- #- ccl
404
379
(defun raw-py (cmd-char &rest code-strings)
405
380
" CMD-CHAR should be #\e for eval and #\x for exec.
406
381
0 commit comments