•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 456,485 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,791 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser: Programming Forums
Views: 550 | Replies: 0
![]() |
•
•
Join Date: Jan 2007
Posts: 58
Reputation:
Rep Power: 2
Solved Threads: 0
I need to create python script that is threaded. So the main program will run in infinite loop and just retrieving messages and putting them in a queue. (Main thread)
I need child threads from a pool to process the queue. When there is no stuff in the queue, they go to the pool and become available but they don't terminate. This has to be done continuously.
Main program need to keep putting stuff in the queue, when there are no messages, then it sleeps for short time and check back to see any messages.
To do this, I guess you don't write joinAll(), so that the main threads just don't wait for the child but goes to work.
am I right?
Also, child threads (a function that is threaded) will make connecitons to the database. I am planning to use threadpool, so that threads reuse the connections. So do you close the database connection at the end of the function? If not then the connection will be opened forever?
I need child threads from a pool to process the queue. When there is no stuff in the queue, they go to the pool and become available but they don't terminate. This has to be done continuously.
Main program need to keep putting stuff in the queue, when there are no messages, then it sleeps for short time and check back to see any messages.
To do this, I guess you don't write joinAll(), so that the main threads just don't wait for the child but goes to work.
am I right?
Also, child threads (a function that is threaded) will make connecitons to the database. I am planning to use threadpool, so that threads reuse the connections. So do you close the database connection at the end of the function? If not then the connection will be opened forever?
![]() |
•
•
•
•
•
•
•
•
DaniWeb Python Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- execute python script from shell/Interactive Window (Python)
- freevo uses python (Python)
- ssh changes the way python script behaves (Python)
- Basic scripting question (Getting Started and Choosing a Distro)
- MIDI script (Shell Scripting)
- Moving to Python From PHP: Using a variable in a function (Python)
- very 1st python tutorial 4 newbies (Python)
Other Threads in the Python Forum
- Previous Thread: any tips on how to get the program to display the first name in the final print strin
- Next Thread: newbee: simple python for loop question


Linear Mode