Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #50935
| References | <6c1a5595-b2f7-4712-8c9c-be664dd8ed18@googlegroups.com> |
|---|---|
| Date | 2013-07-20 11:04 +1000 |
| Subject | Re: how: embed + extend to control my running app? |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4893.1374282263.3114.python-list@python.org> (permalink) |
On Sat, Jul 20, 2013 at 9:52 AM, David M. Cotter <me@davecotter.com> wrote: > i'd like my app to be "available" to python while it's running. > > for example, say my app is "FooBar.app". > > when my FooBar.app is running, now there is a python interface available to python, and the user can write python scripts to make use of it. > > with their scripts, they can control my running application > > when FooBar.app is NOT running, perhaps making use of any of the python functions of "FooBar.app" would either return an error, or possibly launch "FooBar.app"? or do nothing since it's not running? Interfacing C and Python like you suggest can't be done with embedding, because that requires that your app be already running, and probably not by having your code run as a pure module. In fact, I would actually suggest that you devise a separate protocol between your app and the Python script, and run them as separate processes. That way, they run independently, and you may (platform-specific code required here though) be able to invoke your app; most importantly, you'll be able to cleanly handle multiple Python scripts trying to control you simultaneously. What platforms are you aiming at? If it's just for Unix-like ones, the easiest way is probably to create a Unix domain socket, which the Python program can write to and/or read from. With a protocol based around simple operations like that, your Python module need not even involve C code - it simply opens a socket file and uses standard I/O methods on it. Alternatively, you may want to consider a TCP socket, which would let you split the client and server across a network, or possibly direct shared memory access. The world's your oyster. What kind of sauce would you like it with? ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
how: embed + extend to control my running app? "David M. Cotter" <me@davecotter.com> - 2013-07-19 16:52 -0700
Re: how: embed + extend to control my running app? Chris Angelico <rosuav@gmail.com> - 2013-07-20 11:04 +1000
Re: how: embed + extend to control my running app? "David M. Cotter" <me@davecotter.com> - 2013-07-23 22:15 -0700
Re: how: embed + extend to control my running app? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2013-07-24 22:53 +1200
Re: how: embed + extend to control my running app? "David M. Cotter" <me@davecotter.com> - 2013-07-24 09:10 -0700
Re: how: embed + extend to control my running app? Chris Angelico <rosuav@gmail.com> - 2013-07-25 02:25 +1000
Re: how: embed + extend to control my running app? "David M. Cotter" <me@davecotter.com> - 2013-07-24 10:40 -0700
Re: how: embed + extend to control my running app? "David M. Cotter" <me@davecotter.com> - 2013-07-24 12:35 -0700
Re: how: embed + extend to control my running app? "David M. Cotter" <me@davecotter.com> - 2013-07-24 13:37 -0700
Re: how: embed + extend to control my running app? "David M. Cotter" <me@davecotter.com> - 2013-07-24 17:51 -0700
Re: how: embed + extend to control my running app? Dave Angel <davea@davea.name> - 2013-07-24 21:14 -0400
Re: how: embed + extend to control my running app? "David M. Cotter" <me@davecotter.com> - 2013-07-25 11:24 -0700
csiph-web