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(S ERVER_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_It em = MainQueue.Pop()
if (Temp_Current_I tem != N):
server.current_ queue_item = Temp_Current_It em
Execute_Command _str =
ServerSupport.C reateCommand(Te mp_Current_Item )
# Only executes if on a win32 platform.
if (sys.platform == "win32")and(Exe cute_Command_st r != N):
output, input = popen2("cmd.exe ")
input.write(Exe cute_Command_st r+"\n")
input.write("ex it\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 1 2177
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(S ERVER_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_It em = MainQueue.Pop() if (Temp_Current_I tem != N): server.current_ queue_item = Temp_Current_It em
Execute_Command _str = ServerSupport.C reateCommand(Te mp_Current_Item )
# Only executes if on a win32 platform. if (sys.platform == "win32")and(Exe cute_Command_st r != N): output, input = popen2("cmd.exe ") input.write(Exe cute_Command_st r+"\n") input.write("ex it\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****@ActiveSt ate.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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
|
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
os.kill(self.popen.pid, signal.SIGTERM)
Everything works fine on MacOSX. However, I'm doing a port to Solaris (so I
can run it on my web site) and find that the child processes are not
stopping! Solaris is creating TWO new processes: one for the SHELL...
|
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;
|
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 to a pool. If I assign only one
application to a applicaton pool and have multiple worker processes
assigned to that pool. Will my application be processed by many worker
processes?
|
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 servers are in a stateless farm and
have 2 GB of RAM. We are using ASP.NET 1.1 when using a dedicated
application pool for each virtual directory. Each customer gets their own
virtual directory and copy of the ASP.NET dll in their bin folder, which...
| |
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? I've been leaning
towards threads, I'm going to say why.
Processes seem fairly expensive from my research so far. Each fork
copies the entire contents of memory into the new process. There's also
a more expensive context switch between...
|
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 );
|
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 many of the others in the class. We haven't been exposed to any Unix and the professor hasn't, yet, said much more than the book, which is no help at this point.
From what I've figured out and what I've blindly seen on the net and hoped would...
|
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 os.chdir was process-
global.
(2) Next thought was fork, but I don't know how to signal when each
child is
finished.
(3) Current thought is to break the process from a method into a
|
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 packet from scratch so that we have the flexibility to play with different options. This tool is mainly for stress testing routers.
The details are here.
I actually have multiple interfaces created. Each interface will obtain IP addresses using...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |