Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #52344 > unrolled thread
| Started by | Chris Angelico <rosuav@gmail.com> |
|---|---|
| First post | 2013-08-11 03:33 +0100 |
| Last post | 2013-08-11 09:27 -0400 |
| Articles | 5 on this page of 25 — 13 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Am I not seeing the Error? Chris Angelico <rosuav@gmail.com> - 2013-08-11 03:33 +0100
Re: Am I not seeing the Error? Roy Smith <roy@panix.com> - 2013-08-10 22:43 -0400
Re: Am I not seeing the Error? Chris Angelico <rosuav@gmail.com> - 2013-08-11 03:47 +0100
Re: Am I not seeing the Error? Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-08-12 08:33 -0400
Re: Am I not seeing the Error? Zachary Ware <zachary.ware+pylist@gmail.com> - 2013-08-12 08:20 -0500
Re: Am I not seeing the Error? Ned Batchelder <ned@nedbatchelder.com> - 2013-08-12 10:01 -0400
Re: Am I not seeing the Error? Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-08-12 10:04 -0400
Re: Am I not seeing the Error? Roy Smith <roy@panix.com> - 2013-08-12 11:47 -0400
Re: Am I not seeing the Error? Joel Goldstick <joel.goldstick@gmail.com> - 2013-08-12 12:56 -0400
Re: Am I not seeing the Error? Chris Angelico <rosuav@gmail.com> - 2013-08-12 18:19 +0100
Re: Am I not seeing the Error? Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-08-12 16:16 -0400
Re: Am I not seeing the Error? Joel Goldstick <joel.goldstick@gmail.com> - 2013-08-12 16:34 -0400
Re: Am I not seeing the Error? Ned Batchelder <ned@nedbatchelder.com> - 2013-08-12 16:35 -0400
Re: Am I not seeing the Error? Joshua Landau <joshua@landau.ws> - 2013-08-13 09:19 +0100
Re: Am I not seeing the Error? Steven D'Aprano <steve@pearwood.info> - 2013-08-13 08:50 +0000
Re: Am I not seeing the Error? Devyn Collier Johnson <devyncjohnson@gmail.com> - 2013-08-13 06:31 -0400
Re: Am I not seeing the Error? Robert Kern <robert.kern@gmail.com> - 2013-08-13 13:11 +0100
Re: Am I not seeing the Error? Terry Reedy <tjreedy@udel.edu> - 2013-08-13 12:12 -0400
Re: Am I not seeing the Error? Michael Torrie <torriem@gmail.com> - 2013-08-13 19:55 -0600
Re: Am I not seeing the Error? Grant Edwards <invalid@invalid.invalid> - 2013-08-13 13:55 +0000
Re: Am I not seeing the Error? Zachary Ware <zachary.ware+pylist@gmail.com> - 2013-08-12 10:37 -0500
Re: Am I not seeing the Error? Zachary Ware <zachary.ware+pylist@gmail.com> - 2013-08-12 10:47 -0500
Re: Am I not seeing the Error? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-11 08:28 +0000
Re: Am I not seeing the Error? Joshua Landau <joshua@landau.ws> - 2013-08-11 11:18 +0100
Re: Am I not seeing the Error? Roy Smith <roy@panix.com> - 2013-08-11 09:27 -0400
Page 2 of 2 — ← Prev page 1 [2]
| From | Zachary Ware <zachary.ware+pylist@gmail.com> |
|---|---|
| Date | 2013-08-12 10:37 -0500 |
| Message-ID | <mailman.502.1376322196.1251.python-list@python.org> |
| In reply to | #52345 |
On Mon, Aug 12, 2013 at 9:04 AM, Devyn Collier Johnson
<devyncjohnson@gmail.com> wrote:
>
> Zachary, are you, Ned, and Terry trying to say the syntax should be
>
> job = multiprocessing.Process(func1(), func2())
>
> not
>
> job = multiprocessing.Process(func1(); func2())
>
Basically, yes. The first option there is equivalent to this:
func_returns = (func1(), func2())
job = multiprocessing.Process(*func_returns)
The second option is equivalent to this:
job = multiprocessing.Process(func1()
func2())
...which is actually several different syntax errors, depending on how
you look at it. Semi-colon is only ever used in Python as a
substitute for \n-plus-some-spaces. And, since in your original
example, your semi-colons are inside parenthesis, they really have no
effect at all due to implicit line continuation within parens. So
your original line:
JOB_WRITEURGFILES =
multiprocessing.Process(write2file('./mem/ENGINE_PID', ENGINEPID);
write2file(SENTEMPPATH, ''); write2file(INPUTMEM, ''));
JOB_WRITEURGFILES.start()
is really:
JOB_WRITEURGFILES =
multiprocessing.Process(write2file('./mem/ENGINE_PID', ENGINEPID)
write2file(SENTEMPPATH, '') write2file(INPUTMEM, ''))
JOB_WRITEURGFILES.start()
It should be obvious now that the syntax error comes from not
separating the arguments to Process.
Trying to read between the lines a little here, I don't think you have
quite figured out how multiprocessing.Process works; that first option
above will only work if func1 returns None and func2 returns a
callable object and the second has no hope. I think this is more
along the lines of what you're really after:
def process_func():
func1()
func2()
if __name__ == '__main__':
job = multiprocessing.Process(target=process_func) # note: no
() after process_func!
job.start()
I'd suggest giving the multiprocessing.Process docs [0] a good
read-through. Keep in mind that Process is just a type like any other
(str, int, list, etc.), and calling its constructor is subject to the
same rules as any other function call.
--
Zach
[0] http://docs.python.org/3/library/multiprocessing#the-process-class
[toc] | [prev] | [next] | [standalone]
| From | Zachary Ware <zachary.ware+pylist@gmail.com> |
|---|---|
| Date | 2013-08-12 10:47 -0500 |
| Message-ID | <mailman.503.1376322450.1251.python-list@python.org> |
| In reply to | #52345 |
On Mon, Aug 12, 2013 at 10:37 AM, Zachary Ware <zachary.ware+pylist@gmail.com> wrote: > [snip my last reply with a few code samples] My apologies for Gmail's mangling of my samples. Any code that is not indented should be on the previous line. -- Zach
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2013-08-11 08:28 +0000 |
| Message-ID | <52074b43$0$30000$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #52344 |
On Sun, 11 Aug 2013 03:33:52 +0100, Chris Angelico wrote: > Next thing to do is split it into more lines. Why is all that in a > single line? The only good excuse for writing multiple statements on a single line separated by semi-colons is if the Enter key on your keyboard is broken. :-) -- Steven
[toc] | [prev] | [next] | [standalone]
| From | Joshua Landau <joshua@landau.ws> |
|---|---|
| Date | 2013-08-11 11:18 +0100 |
| Message-ID | <mailman.477.1376216323.1251.python-list@python.org> |
| In reply to | #52368 |
On 11 August 2013 09:28, Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote: > into more lines. Why is all that in a >> single line? > > The only good excuse for writing multiple statements on a single line > separated by semi-colons is if the Enter key on your keyboard is broken. That's not a good excuse. It *is* a good excuse for any of the following: * Buying a new keyboard * Using a new keymap, possibly replacing cAPSLOCK with Return * Crying
[toc] | [prev] | [next] | [standalone]
| From | Roy Smith <roy@panix.com> |
|---|---|
| Date | 2013-08-11 09:27 -0400 |
| Message-ID | <roy-152703.09270411082013@news.panix.com> |
| In reply to | #52368 |
In article <52074b43$0$30000$c3e8da3$5496439d@news.astraweb.com>, Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote: > On Sun, 11 Aug 2013 03:33:52 +0100, Chris Angelico wrote: > > > Next thing to do is split it into more lines. Why is all that in a > > single line? > > The only good excuse for writing multiple statements on a single line > separated by semi-colons is if the Enter key on your keyboard is broken. Well, maybe if you're testing something on the command line with "python -c".
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | comp.lang.python
csiph-web