[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

How to start background processes in Python?

Posted on 2014-12-24
3
Medium Priority
?
393 Views
Last Modified: 2014-12-28
Hello,

I'm trying to
  * read a file
  * write some data into a folder
  * start another process to process the data
  * resume reading the file while the process works on the data

Is there a good way to go about doing this? Would it be better than starting a bunch of threads?

The reason I'm thinking about it this way, is that I don't really need the processes to communicate with each other, once started, the processes will be working on their own set of data; and I'm hoping Unix would manage running multiple scripts better than Python would manage threads.

Appreciate any advice on this!
0
Comment
Question by:Errang Genevre
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 1400 total points
ID: 40517414
You spawn a process by invoking the subprocess function.

You have a potential race condition in that the second process won't know exactly when the Python process is done writing the file (unless these are fixed-size files), so you might want to use a convention like writing a zero-byte sentinel file to alert the subprocess as to when the file is done being written. Unless, of course, you won't be kicking off the 2nd process until the Python process finishes writing the file.
0
 
LVL 25

Assisted Solution

by:clockwatcher
clockwatcher earned 600 total points
ID: 40518156
Might be a little overkill for what you're after but it sounds like a good candidate for a message queuing system:  https://www.rabbitmq.com/tutorials/tutorial-two-python.html
0
 

Author Closing Comment

by:Errang Genevre
ID: 40520677
Thanks!
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question