Python Forum
How to timeout a task using the ThreadpoolExecutor?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to timeout a task using the ThreadpoolExecutor?
#2
Hi,

I'm not sure if I understand your question correctly, but the concurent.futures module is not meant for a "fire and forgot" mode. The executors wait until tasks are finished. As the documentation for the ThreadPoolExecutor says: "All threads enqueued to ThreadPoolExecutor will be joined before the interpreter can exit.". Which means your problem blocks at one point.

If you are looking for background processing where new task can be fed any time, you may build something yourself using two threads or processes connected by a queue or you use an asyncronous task queue like e.g. Celery (or one of the lighter options).

Gruß, noisefloor
Reply


Messages In This Thread
RE: How to timeout a task using the ThreadpoolExecutor? - by noisefloor - Feb-07-2023, 05:02 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  count certain task in task manager[solved] kucingkembar 2 1,221 Aug-29-2022, 05:57 PM
Last Post: kucingkembar
  FTp timeout except korenron 2 3,734 Feb-01-2022, 06:51 AM
Last Post: korenron
  Schedule a task and render/ use the result of the task in any given time klllmmm 2 2,205 May-04-2021, 10:17 AM
Last Post: klllmmm
  How to create a task/import a task(task scheduler) using python Tyrel 7 3,944 Feb-11-2021, 11:45 AM
Last Post: Tyrel
  Trying to understand concurrent.futures.ThreadPoolExecutor Laxminarsaiah 0 1,674 Dec-18-2019, 12:43 PM
Last Post: Laxminarsaiah
  ThreadPoolExecutor read file to list DaLiPy 3 6,395 Jun-11-2019, 05:55 AM
Last Post: DaLiPy
  timeout value in subprocess jonesin1974 2 5,189 Dec-01-2017, 02:18 PM
Last Post: snippsat
  AsyncSSH and timeout Standard_user 1 5,619 Nov-03-2016, 06:05 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020