Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #52419

Re: Am I not seeing the Error?

References (2 earlier) <roy-4A9C13.22431010082013@news.panix.com> <CAPTjJmoA+r3ABByjgMNC-23H0tB95r6S+d04T-KF-3xgbCNSOQ@mail.gmail.com> <5208D625.2000103@Gmail.com> <CAKJDb-P-TEqmGV45dbayaLdqh2nXE_FyLbd4dk7CPpcTsFWciQ@mail.gmail.com> <5208EB7E.6030907@Gmail.com>
From Zachary Ware <zachary.ware+pylist@gmail.com>
Date 2013-08-12 10:37 -0500
Subject Re: Am I not seeing the Error?
Newsgroups comp.lang.python
Message-ID <mailman.502.1376322196.1251.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

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

csiph-web