473,387 Members | 1,582 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,387 software developers and data experts.

Processes.

Guy
Hi

I've done some projects in python for my work which invole some test
scripts etc. All quite basic stuff, I find python a good language to
work in but have come up against a brick wall. I'm been searching
google for hours about processes pids etc. My problem is as follows
the main problem code can be seen below :

server = uc_server(HOST_str, PORT_num)
while 1:
asyncore.poll(SERVER_TIMEOUT)

# Only pops queue when the current item is blank.
if (server.current_queue_item == [0,"","",["",0],["",""]]):
# Pops a queue item if there are any queue items to get.
Temp_Current_Item = MainQueue.Pop()
if (Temp_Current_Item != N):
server.current_queue_item = Temp_Current_Item

Execute_Command_str =
ServerSupport.CreateCommand(Temp_Current_Item)

# Only executes if on a win32 platform.
if (sys.platform == "win32")and(Execute_Command_str != N):
output, input = popen2("cmd.exe")
input.write(Execute_Command_str+"\n")
input.write("exit\n")

while 1:
text = output.readline()
if text:
print text
else:
# Sets the current queue item to blank.
server.current_queue_item =
[0,"","",["",0],["",""]]
break

What I want to have is a server which is multi platform win32,
unix(lots of differnt sorts and may be mac later but forget mac for
now.) that people can telnet onto leave a job, and then the server
runs the jobs one at a time.
What I have is a server that people can telnet on to leave a job, the
server will execute it and keep executing it until it is done. I
thought that maybe the poll thing would sort this out by switching
from the main body of the script to the server part of the script, but
it didn't. The way that I use popen2 is my fav. way of executing
processes as I can catcher all output. What would be really good if I
could execute commands or scripts by using child processes and
searching for there pids this way I would know whats running on the
box at any one time.
There's loads about pids processes on google but it mainly in unix, I
mainly want it in win32 which there is hardly anything about.

Please Please Help

TIA
TTFN
Guy
Jul 18 '05 #1
1 2106

Guy,

Basically working with processes in a cross-platform manner is a pain.
:) Yes PIDs are more of a Linux/Unix thing. I think they do exist to a
degree on Windows but that would only be as part of Windows' weak posix
compliance layer. In Windows you generally want to talk about process
handles. However, Python's standard process handling stuff doesn't
generally expose the handles for started processes. I have a module
called process.py that might help do what you want to do. Give it a try:
http://starship.python.net/crew/tmick/#process

Cheers,
Trent
[Guy wrote]
Hi

I've done some projects in python for my work which invole some test
scripts etc. All quite basic stuff, I find python a good language to
work in but have come up against a brick wall. I'm been searching
google for hours about processes pids etc. My problem is as follows
the main problem code can be seen below :

server = uc_server(HOST_str, PORT_num)
while 1:
asyncore.poll(SERVER_TIMEOUT)

# Only pops queue when the current item is blank.
if (server.current_queue_item == [0,"","",["",0],["",""]]):
# Pops a queue item if there are any queue items to get.
Temp_Current_Item = MainQueue.Pop()
if (Temp_Current_Item != N):
server.current_queue_item = Temp_Current_Item

Execute_Command_str =
ServerSupport.CreateCommand(Temp_Current_Item)

# Only executes if on a win32 platform.
if (sys.platform == "win32")and(Execute_Command_str != N):
output, input = popen2("cmd.exe")
input.write(Execute_Command_str+"\n")
input.write("exit\n")

while 1:
text = output.readline()
if text:
print text
else:
# Sets the current queue item to blank.
server.current_queue_item =
[0,"","",["",0],["",""]]
break

What I want to have is a server which is multi platform win32,
unix(lots of differnt sorts and may be mac later but forget mac for
now.) that people can telnet onto leave a job, and then the server
runs the jobs one at a time.
What I have is a server that people can telnet on to leave a job, the
server will execute it and keep executing it until it is done. I
thought that maybe the poll thing would sort this out by switching
from the main body of the script to the server part of the script, but
it didn't. The way that I use popen2 is my fav. way of executing
processes as I can catcher all output. What would be really good if I
could execute commands or scripts by using child processes and
searching for there pids this way I would know whats running on the
box at any one time.
There's loads about pids processes on google but it mainly in unix, I
mainly want it in win32 which there is hardly anything about.

Please Please Help

TIA
TTFN
Guy
--
http://mail.python.org/mailman/listinfo/python-list


--
Trent Mick
Tr****@ActiveState.com

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Markus Franz | last post by:
Hi. I created a little script: for currenturl in sys.argv: pid = os.fork() if pid == 0: signal.alarm(10) do_something() # placeholder for the download and print routine
6
by: Bob Swerdlow | last post by:
My application starts up a number of processes for various purposes using: self.popen = popen2.Popen3("/usr/local/bin/python -O "myscript.py") and then shuts them down when appropriate with...
15
by: Dirk Reske | last post by:
Hello, why doesn't this code work correctly? private int GetCpuUsage(Process proc) { DateTime time1,time2; TimeSpan timediff; double cpu1,cpu2,cpudiff;
9
by: Abhishek Srivastava | last post by:
Hello All, In IIS 6.0 We have a concept of worker processes and application pools. As I understand it, we can have multiple worker process per appliction pool. Each worker process is dedicated...
4
by: AN | last post by:
Greetings, We make an ASP.NET web application and we host it for our customers. We have provisioned hardware and hope to be able to service around 200 customers on this hardware. The web...
35
by: Carl J. Van Arsdall | last post by:
Alright, based a on discussion on this mailing list, I've started to wonder, why use threads vs processes. So, If I have a system that has a large area of shared memory, which would be better? ...
3
by: xxs | last post by:
I have writen some codes as follow: #include <windows.h> #include <tlhelp32.h> #include <stdio.h> // Forward declarations: BOOL GetProcessList( ); BOOL ListProcessModules( DWORD dwPID...
1
by: jazon | last post by:
Let me start by saying this for an Operating Systems class. No, I don't expect the work to be done for me. The assignment is as follows: To be honest, I feel like a fish out of water, like...
6
by: Tim Arnold | last post by:
I have a bunch of processes to run and each one needs its own working directory. I'd also like to know when all of the processes are finished. (1) First thought was threads, until I saw that...
1
by: umaramnath | last post by:
Hello everyone, I work on Linux for ARM processor for cable modem. There is a tool that I have written (as the job demands) that sends/storms customized UDP packets using raw sockets. I form the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...

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.