Re: [Py4j-users] Starting/stopping py4j server from within python?
Status: Beta
Brought to you by:
barthe
From: Thomas N. <tom...@gm...> - 2014-12-08 21:19:20
|
Great that's a nice way to avoid sending any explicit kill signals. Also that's probably easy enough for my users to manage. What would be really nice is if there could be some sort of garbage collector hook that would send the shutdown signal automatically. That way you could maybe create a class that automatically started the server and then when whatever you're using goes out of scope, your hook could shutdown the server. I'm sure something like this is theoretically possible, but I've never worked with that sort of thing. Then maybe on init one could check if the port is in use (i.e. by another py4j server) and choose a different port in that case. This is all probably overkill though. Your method is great for now. Thanks! On 12/08/2014 04:09 PM, Barthelemy Dagenais wrote: > Hi, > > it depends on your use case. Most of the examples start a server in > the Java main method so if you do gateway.shutdown() on the Python > side, it will (1) send a shutdown signal on the Java side, (2) the > Java server will stops, and (3) because there are no more active > threads, the JVM will exit. > > You can even do something harsher from Python: > > gateway.jvm.System.exit(0) > > Does that help? > > Barthelemy > > On Mon, Dec 8, 2014 at 3:46 PM, Thomas Nyberg <tom...@gm...> wrote: >> Hello, >> >> What would be the best way for me to start and stop the py4j server from >> within python? I know I could use >> >> > os.system("java ...") >> >> to start the server. I guess I would need a subprocess for that not to >> block. Then to stop it I could send it a kill signal. Is this the best >> way to do it? Is there a way for me to do this in a less >> directly-managed fashion? This is okay for me, but the users of what I'm >> making probably would have trouble... >> >> Cheers, >> Thomas >> >> ------------------------------------------------------------------------------ >> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server >> from Actuate! Instantly Supercharge Your Business Reports and Dashboards >> with Interactivity, Sharing, Native Excel Exports, App Integration & more >> Get technology previously reserved for billion-dollar corporations, FREE >> http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk >> _______________________________________________ >> Py4j-users mailing list >> Py4...@li... >> https://lists.sourceforge.net/lists/listinfo/py4j-users > > ------------------------------------------------------------------------------ > Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server > from Actuate! Instantly Supercharge Your Business Reports and Dashboards > with Interactivity, Sharing, Native Excel Exports, App Integration & more > Get technology previously reserved for billion-dollar corporations, FREE > http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk > _______________________________________________ > Py4j-users mailing list > Py4...@li... > https://lists.sourceforge.net/lists/listinfo/py4j-users > |