40ants / lisp-project-of-the-day

Here I'll post notes about Quicklisp projects. Also I publish them on Twitter account svetlyak40wt.
http://40ants.com/lisp-project-of-the-day/
BSD 2-Clause "Simplified" License
51 stars 6 forks source link

cl-reddit #10

Open utterances-bot opened 4 years ago

utterances-bot commented 4 years ago

cl-reddit

https://40ants.com/lisp-project-of-the-day/2020/06/0096-cl-reddit.html

vindarel commented 4 years ago

mmh let me check, I am using Dexador with Lparallel.

With comments:

  ;; Sometimes, after a C-z or hibernation,
  ;; if we don't recreate the kernel, netwwork requests can hang.
  (setf lparallel:*kernel* nil)
  (setf lparallel:*kernel* (lparallel:make-kernel 4))
   (get-all-titles)
   …

;; where get-all-titles contains:
    (lparallel:pmap 'list #'get-titles)

;; and get-titles contains:
  (dex:get url)

As says the comment I have experienced hickups (timeouts too?) if I create the lparalell kernel, pauses my computer and run the high-level function again, without creating a new kernel. Hope that helps.

svetlyak40wt commented 4 years ago

Do you know, when you are doing (setf lparallel:*kernel* nil) it does not destroy lparallel's threads and they can stay in the system and eat resources?

I have this function to stop these workers completely:

(def (function e) stop-lparallel-threads ()
  (setf lparallel.kernel::*lisp-exiting-p* t)
  (unwind-protect
       (loop for thread in (bt:all-threads)
             when (string= (bt:thread-name thread)
                           "LParallel")
             do (bt:destroy-thread thread))
    (sleep 5)
    (setf lparallel.kernel::*lisp-exiting-p* nil)))

Here "LParallel" is the name, I passed to the lparallel:make-kernel as :name argument.

svetlyak40wt commented 4 years ago

Without settings lparallel.kernel::*lisp-exiting-p* to t, all lparallel threads are relaunched automatically by a supervisor thread.