473,401 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Copies of Code

Has anyone tried to run several copies of the same python code in the background? Let me explain. What I need to do is open 50 or so different folders and do operations on the stuff inside each folder. It works fine in serial, open folder1, do work, open folder2, do work etc. But this takes a long time, order of 3-4 hours. So I was trying to get it to run concurrently.

The way I was planning on doing this was by calling each instance of the python code from a bash script. Here it is for four folders.

Expand|Select|Wrap|Line Numbers
  1. #!/bin/sh
  2. for i in $(seq 0 3);
  3. do
  4.         python calculate.py $i  &
  5. done
  6. wait
  7. exit 0
  8.  
The script takes the number as an argument and uses that number to open the appropriate folder.

Now here is the problem. When I run this script, folder0 is worked on correctly. The other 3 folders are not. Here is some output.

Expand|Select|Wrap|Line Numbers
  1. -bash-3.1$ ./test.sh 
  2. Engage the System
  3. Engage the System
  4. Engage the System
  5. Engage the System
  6. reading `/tmp/shared/sqb/folder0/snapshot_000' ...
  7. Error: can't open file.
  8. allocating memory...done
  9. Error: can't open file.
  10. Error: can't open file.
  11. reordering...done.
  12. space for particle ID freed
  13. DONE
  14. DONE
  15. DONE
  16. .
  17. .
  18. folder0 is being worked on... 
  19. .
  20. .
  21. DONE
  22.  
I assume that the "Error: can't open file" is a python error. Has anyone tried to do something like this before?

Thanks for all your help
Jan 22 '09 #1
1 1427
Check if the files that the python script manipulates are present in the corresponding folders the script is expected to work fine in that case e.g:

Dir structure
readir.py
test0/testfile0.py
test1/testfile1.py
test.sh
Expand|Select|Wrap|Line Numbers
  1. #!/bin/sh
  2. for i in $(seq 0 1);
  3. do
  4.    python readir.py $i  &
  5. done
  6. wait
  7. exit 0
  8.  
The python code would just print the contents of the directory
Expand|Select|Wrap|Line Numbers
  1. import os
  2. import sys
  3.  
  4. exec "os.chdir('test%s'%sys.argv[1])"
  5. print os.listdir('.')
The script works fine for me
o/p
['testfile1.py']
['testfile0.py']
Jan 23 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Henning Kage | last post by:
I'm using Python only for some months now and I'm wondering, whether such assignments as above are creating bitwise copies of an object or just recieve a reference. That means I wanted to know,...
11
by: Dan Stromberg | last post by:
We will soon have 3 copies, for testing purposes, of what should be about 4.5 terrabytes of data. Rather than cmp'ing twice, to verify data integrity, I was thinking we could speed up the...
1
by: jsnX | last post by:
hi, i would like to make some code that operates on sets of points - does convex hulls and other operations. but it looks like i will need a lot of pointless object copies: ...
9
by: David Allison | last post by:
cmdButton to Print 3 copies of record in Form view ? cmdButton will print 1 but I need 3 copies of the one Form record. -- Dave Allison
8
by: Hank Reed | last post by:
Hello, I have searched through dozens of old responses to this question but have been unable to make it work in my situation. I'm using Access 2000 We have a very old sticker printer on a...
3
by: TDIOwa | last post by:
I have a report printing form (Access 97) in which I print different reports from. I have added a combo box that selects the number of copies that I want to print. Here is the rub... The...
3
by: Tim | last post by:
Is it possible to select the number of copies of a report from a variable input in a form ? -- Tim Patton ICT Controller Springfarm Architectural Mouldings Ltd Antrim, N.Ireland
4
by: Adam - Regus | last post by:
I'm trying to create a button that prints 2 copies of a form. Using the wizard, I created a button that prints one automatically, using the following code: End Sub Private Sub...
12
by: eyalco | last post by:
I have a report which I need to copy in 2 different lables. I've set a table with numbers from 0-10 (0 gets "original and all the others get "copy"). The caption is changed by IIF - so now all is ok....
1
by: ccmanc68 | last post by:
I would like to print two reports a once. The first report is a sign sheet; the second is an order form. The sign sheet contains the same information as the order form but has a different layout. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.