[GRASS-SVN] r58579 - in grass/trunk/lib/python: pygrass/messages temporal
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Jan 1 18:53:01 PST 2014
Author: huhabla
Date: 2014-01-01 18:53:00 -0800 (Wed, 01 Jan 2014)
New Revision: 58579
Modified:
grass/trunk/lib/python/pygrass/messages/__init__.py
grass/trunk/lib/python/temporal/c_libraries_interface.py
grass/trunk/lib/python/temporal/core.py
grass/trunk/lib/python/temporal/register.py
grass/trunk/lib/python/temporal/unittests_register.py
Log:
Better exit handling of messenger and C-interface subprocesses
Modified: grass/trunk/lib/python/pygrass/messages/__init__.py
===================================================================
--- grass/trunk/lib/python/pygrass/messages/__init__.py 2014-01-02 01:44:15 UTC (rev 58578)
+++ grass/trunk/lib/python/pygrass/messages/__init__.py 2014-01-02 02:53:00 UTC (rev 58579)
@@ -14,6 +14,7 @@
@author Soeren Gebbert
"""
+import logging
import sys
import grass.lib.gis as libgis
from multiprocessing import Process, Lock, Pipe
@@ -28,8 +29,6 @@
def __str__(self):
return self.value
-
-
def message_server(lock, conn):
"""!The GRASS message server function designed to be a target for
multiprocessing.Process
@@ -64,6 +63,8 @@
- Debug: ["DEBUG", level, "MESSAGE"]
- Percent: ["PERCENT", n, d, s]
"""
+ libgis.G_debug(1, "Start messenger server")
+
while True:
# Avoid busy waiting
conn.poll(None)
@@ -77,7 +78,8 @@
if message_type == "STOP":
conn.close()
lock.release()
- return
+ libgis.G_debug(1, "Stop messenger server")
+ sys.exit()
message = data[1]
Modified: grass/trunk/lib/python/temporal/c_libraries_interface.py
===================================================================
--- grass/trunk/lib/python/temporal/c_libraries_interface.py 2014-01-02 01:44:15 UTC (rev 58578)
+++ grass/trunk/lib/python/temporal/c_libraries_interface.py 2014-01-02 02:53:00 UTC (rev 58579)
@@ -571,9 +571,10 @@
###############################################################################
def _stop(lock, conn, data):
- conn.close()
- lock.release()
- sys.exit()
+ conn.close()
+ lock.release()
+ libgis.G_debug(1, "Stop C-interface server")
+ sys.exit()
###############################################################################
@@ -595,6 +596,7 @@
functions[RPCDefs.MAP_EXISTS] = _map_exists
libgis.G_gisinit("c_library_server")
+ libgis.G_debug(1, "Start C-interface server")
while True:
# Avoid busy waiting
Modified: grass/trunk/lib/python/temporal/core.py
===================================================================
--- grass/trunk/lib/python/temporal/core.py 2014-01-02 01:44:15 UTC (rev 58578)
+++ grass/trunk/lib/python/temporal/core.py 2014-01-02 02:53:00 UTC (rev 58579)
@@ -57,6 +57,8 @@
except:
pass
+import atexit
+
###############################################################################
# Profiling function provided by the temporal framework
@@ -315,6 +317,20 @@
###############################################################################
+def stop_subprocesses():
+ """!Stop the messenger and C-interface subprocesses
+ """
+ global message_interface
+ global c_library_interface
+ if message_interface:
+ message_interface.stop()
+ if c_library_interface:
+ c_library_interface.stop()
+
+atexit.register(stop_subprocesses)
+
+###############################################################################
+
def init():
"""!This function set the correct database backend from GRASS environmental variables
and creates the grass location database structure for raster,
Modified: grass/trunk/lib/python/temporal/register.py
===================================================================
--- grass/trunk/lib/python/temporal/register.py 2014-01-02 01:44:15 UTC (rev 58578)
+++ grass/trunk/lib/python/temporal/register.py 2014-01-02 02:53:00 UTC (rev 58579)
@@ -61,7 +61,6 @@
time and an increment is provided
@param fs Field separator used in input file
"""
-
start_time_in_file = False
end_time_in_file = False
msgr = get_tgis_message_interface()
Modified: grass/trunk/lib/python/temporal/unittests_register.py
===================================================================
--- grass/trunk/lib/python/temporal/unittests_register.py 2014-01-02 01:44:15 UTC (rev 58578)
+++ grass/trunk/lib/python/temporal/unittests_register.py 2014-01-02 02:53:00 UTC (rev 58579)
@@ -27,7 +27,7 @@
w=0.0, t=1.0, b=0.0, res=10.0)
def setUp(self):
- """!Create the test maps
+ """!Create the test maps and the space time raster datasets
"""
ret = 0
ret += grass.run_command("r.mapcalc", overwrite=True, quiet=True,
More information about the grass-commit
mailing list