473,387 Members | 1,502 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.

How to Start a (thread?) and Leave

Here's my situation, would you folks be so kind as to reccomend an
approach?

I have a small Python CGI script running as an intranet app. One of
the things the script needs to do is allow users to save invoices.
This is a process that takes about 60 seconds once the user submits
the order from the web app.

Ideally I'd like the CGI script to kick off a process to save the
invoice but not wait until it's finished to render the page. What's
the best way to do this, a thread, call a separate program from
os.system, something else?

Thanks in advance for the help.

-Greg

Mar 9 '07 #1
8 1226
probably a Thread.

Mar 9 '07 #2
On Mar 9, 3:25 pm, "abcd" <codecr...@gmail.comwrote:
probably a Thread.

But a thread leaves the script running until the thread exits, right?
So the webpage would just keep saying "loading" at the bottom I think.

-Greg

Mar 9 '07 #3
But a thread leaves the script running until the thread exits, right?
So the webpage would just keep saying "loading" at the bottom I think.

-Greg
give it a shot. if you spawn off a new thread your code should keep
executing while the thread does its work in the "background".

Mar 9 '07 #4
On Mar 9, 3:45 pm, "abcd" <codecr...@gmail.comwrote:
But a thread leaves the script running until the thread exits, right?
So the webpage would just keep saying "loading" at the bottom I think.
-Greg

give it a shot. if you spawn off a new thread your code should keep
executing while the thread does its work in the "background".

That's the thing though, I don't want my code to keep executing, I
want the script to exit/finish completely.

I'm leaning towards os.startfile right now. I also see some os.spawn
beasties in there but I don't understand those.

-Greg

Mar 9 '07 #5

<gr********@gmail.comwrote in message
news:11**********************@h3g2000cwc.googlegro ups.com...
| On Mar 9, 3:25 pm, "abcd" <codecr...@gmail.comwrote:
| probably a Thread.
|
|
| But a thread leaves the script running until the thread exits, right?
| So the webpage would just keep saying "loading" at the bottom I think.

Can you tell the page to auto-refresh itself every 15 seconds or so? I
have seen this as a user but don't know if it is special html code or
javascript or java or what.

tjr

Mar 9 '07 #6
On Mar 9, 4:57 pm, "Terry Reedy" <tjre...@udel.eduwrote:
<gregpin...@gmail.comwrote in message

news:11**********************@h3g2000cwc.googlegro ups.com...
Can you tell the page to auto-refresh itself every 15 seconds or so? I
have seen this as a user but don't know if it is special html code or
javascript or java or what.

tjr
That's a good point. I'll check into that. If not it looks like I'll
be going with os.spawn.

Mar 9 '07 #7
On Mar 9, 4:57 pm, "Terry Reedy" <tjre...@udel.eduwrote:
<gregpin...@gmail.comwrote in message

news:11**********************@h3g2000cwc.googlegro ups.com...
| On Mar 9, 3:25 pm, "abcd" <codecr...@gmail.comwrote:
Can you tell the page to auto-refresh itself every 15 seconds or so? I
have seen this as a user but don't know if it is special html code or
javascript or java or what.

tjr
This will sort of emulate the stop button, that might work:
http://www.thescripts.com/forum/thread601992.html

-Greg

Mar 9 '07 #8
In article <11**********************@8g2000cwh.googlegroups.c om>,
gr********@gmail.com <gr********@gmail.comwrote:
>
I'm leaning towards os.startfile right now. I also see some os.spawn
beasties in there but I don't understand those.
Try the subprocess module
--
Aahz (aa**@pythoncraft.com) <* http://www.pythoncraft.com/

"I disrespectfully agree." --SJM
Mar 14 '07 #9

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

Similar topics

0
by: fowlertrainer | last post by:
Hello ! I have been created a Zope (Python) Product. But it is must store inner global definitions (some conversion parameters), what I need to change in only one thread, or only once. See...
7
by: Morris | last post by:
I want to abort a running thread, so I call MyThread.abort() function. My problem is this thread runs "almost" like a while(true) loop and I don't want the Abort() function interrupts the thread at...
1
by: Novice | last post by:
Hi all, I have written some code that invokes a method a few hundred times and then it immediately finishes. I would like it to instead: 1. start the hundreds of threads (asynchronously) 2....
37
by: ales | last post by:
Hello, I have a problem with creation of new thread. The method .Start() of newly created thread delays current thread for 0 - 1 second. Cpu while delay occurs is about 5%. Any idea? Here...
16
by: pamelafluente | last post by:
I am still working with no success on that client/server problem. I need your help. I will submit simplified versions of my problem so we can see clearly what is going on. My model: A client...
10
by: Doug Robertson | last post by:
First off, I'm a hardware/OS guy. I just write code on the side and I'm completely self taught - so bear in mind my total lack of expertise. I have a program originally written in VB2003 using...
0
by: Yue Fei | last post by:
I have a multi thread python code, threads can start immediately if I run on command line, but I can get them started right the way if I call the same code from C/C++. test code like this: from...
29
by: NvrBst | last post by:
I've read a bit online seeing that two writes are not safe, which I understand, but would 1 thread push()'ing and 1 thread pop()'ing be thread-safe? Basically my situation is the follows: ...
12
by: Ronny | last post by:
Thanks Chris, Looks nice but I miss the dual way communication. In the main thread to deliver paramters and data to the worker thread- how can I do that? Regards Ronny Take a look at the...
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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.