Merge lp:~cmiller/desktopcouch/service-exits-properly into lp:desktopcouch

Proposed by Chad Miller
Status: Merged
Approved by: dobey
Approved revision: 276
Merged at revision: 275
Proposed branch: lp:~cmiller/desktopcouch/service-exits-properly
Merge into: lp:desktopcouch
Diff against target: 98 lines (+28/-7)
2 files modified
desktopcouch/application/service.py (+23/-6)
desktopcouch/application/tests/test_service.py (+5/-1)
To merge this branch: bzr merge lp:~cmiller/desktopcouch/service-exits-properly
Reviewer Review Type Date Requested Status
dobey (community) Approve
Eric Casteleijn (community) Approve
Review via email: mp+58964@code.launchpad.net

Commit message

Shut down every child when service exits. On SIGTERM or SIGHUP, exit gracefully. (LP: 597197)

To post a comment you must log in.
Revision history for this message
Eric Casteleijn (thisfred) :
review: Approve
Revision history for this message
dobey (dobey) :
review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (119.4 KiB)

The attempt to merge lp:~cmiller/desktopcouch/service-exits-properly into lp:desktopcouch failed. Below is the output from the failed tests.

Apache CouchDB has started, time to relax.
Browse your desktop CouchDB at file:///tmp/tmpaiH_vP/data/couchdb.html
desktopcouch.application.migration.tests.test_migration
  TestMigration
    test_migration_deleted_flag_to_trash ... Traceback (most recent call last):
  File "/usr/lib/python2.7/unittest/case.py", line 312, in run
    self.setUp()
  File "/home/otto/tarmac-builds/desktopcouch/trunk/desktopcouch/application/migration/tests/test_migration.py", line 105, in setUp
    super(TestMigration, self).setUp()
  File "/home/otto/tarmac-builds/desktopcouch/trunk/desktopcouch/application/migration/tests/test_migration.py", line 57, in setUp
    self.database = DesktopDatabase(self.dbname, create=True, ctx=self.ctx)
  File "/home/otto/tarmac-builds/desktopcouch/trunk/desktopcouch/application/server.py", line 75, in __init__
    oauth_tokens=oauth_tokens, ctx=ctx, views_factory=views_factory)
  File "/home/otto/tarmac-builds/desktopcouch/trunk/desktopcouch/records/database.py", line 123, in __init__
    self._reconnect()
  File "/home/otto/tarmac-builds/desktopcouch/trunk/desktopcouch/application/server.py", line 85, in _reconnect
    super(DesktopDatabase, self)._reconnect(uri=uri)
  File "/home/otto/tarmac-builds/desktopcouch/trunk/desktopcouch/records/database.py", line 139, in _reconnect
    self._server.create(self._database_name)
  File "/usr/lib/pymodules/python2.7/couchdb/client.py", line 193, in create
    self.resource.put_json(validate_dbname(name))
  File "/usr/lib/pymodules/python2.7/couchdb/http.py", line 405, in put_json
    status, headers, data = self.put(*a, **k)
  File "/usr/lib/pymodules/python2.7/couchdb/http.py", line 384, in put
    return self._request('PUT', path, body=body, headers=headers, **params)
  File "/usr/lib/pymodules/python2.7/couchdb/http.py", line 419, in _request
    credentials=self.credentials)
  File "/home/otto/tarmac-builds/desktopcouch/trunk/desktopcouch/records/http.py", line 259, in request
    raise ServerError((status, error))
couchdb.http.ServerError: (400, ('invalid_consumer_token_pair', 'Invalid consumer and token pair.'))
[ERROR]
    test_migration_in_face_of_broken_records ... Traceback (most recent call last):
  File "/usr/lib/python2.7/unittest/case.py", line 312, in run
    self.setUp()
  File "/home/otto/tarmac-builds/desktopcouch/trunk/desktopcouch/application/migration/tests/test_migration.py", line 105, in setUp
    super(TestMigration, self).setUp()
  File "/home/otto/tarmac-builds/desktopcouch/trunk/desktopcouch/application/migration/tests/test_migration.py", line 57, in setUp
    self.database = DesktopDatabase(self.dbname, create=True, ctx=self.ctx)
  File "/home/otto/tarmac-builds/desktopcouch/trunk/desktopcouch/application/server.py", line 75, in __init__
    oauth_tokens=oauth_tokens, ctx=ctx, views_factory=views_factory)
  File "/home/otto/tarmac-builds/desktopcouch/trunk/desktopcouch/records/database.py", line 123, in __init__
    self._reconnect()
  File "/home/otto/tarmac-builds/desktopcouch/trunk/desktopcouch/application/server.py", l...

Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (119.4 KiB)

The attempt to merge lp:~cmiller/desktopcouch/service-exits-properly into lp:desktopcouch failed. Below is the output from the failed tests.

Apache CouchDB has started, time to relax.
Browse your desktop CouchDB at file:///tmp/tmp36oZ76/data/couchdb.html
desktopcouch.application.migration.tests.test_migration
  TestMigration
    test_migration_deleted_flag_to_trash ... Traceback (most recent call last):
  File "/usr/lib/python2.7/unittest/case.py", line 312, in run
    self.setUp()
  File "/home/otto/tarmac-builds/desktopcouch/trunk/desktopcouch/application/migration/tests/test_migration.py", line 105, in setUp
    super(TestMigration, self).setUp()
  File "/home/otto/tarmac-builds/desktopcouch/trunk/desktopcouch/application/migration/tests/test_migration.py", line 57, in setUp
    self.database = DesktopDatabase(self.dbname, create=True, ctx=self.ctx)
  File "/home/otto/tarmac-builds/desktopcouch/trunk/desktopcouch/application/server.py", line 75, in __init__
    oauth_tokens=oauth_tokens, ctx=ctx, views_factory=views_factory)
  File "/home/otto/tarmac-builds/desktopcouch/trunk/desktopcouch/records/database.py", line 123, in __init__
    self._reconnect()
  File "/home/otto/tarmac-builds/desktopcouch/trunk/desktopcouch/application/server.py", line 85, in _reconnect
    super(DesktopDatabase, self)._reconnect(uri=uri)
  File "/home/otto/tarmac-builds/desktopcouch/trunk/desktopcouch/records/database.py", line 139, in _reconnect
    self._server.create(self._database_name)
  File "/usr/lib/pymodules/python2.7/couchdb/client.py", line 193, in create
    self.resource.put_json(validate_dbname(name))
  File "/usr/lib/pymodules/python2.7/couchdb/http.py", line 405, in put_json
    status, headers, data = self.put(*a, **k)
  File "/usr/lib/pymodules/python2.7/couchdb/http.py", line 384, in put
    return self._request('PUT', path, body=body, headers=headers, **params)
  File "/usr/lib/pymodules/python2.7/couchdb/http.py", line 419, in _request
    credentials=self.credentials)
  File "/home/otto/tarmac-builds/desktopcouch/trunk/desktopcouch/records/http.py", line 259, in request
    raise ServerError((status, error))
couchdb.http.ServerError: (400, ('invalid_consumer_token_pair', 'Invalid consumer and token pair.'))
[ERROR]
    test_migration_in_face_of_broken_records ... Traceback (most recent call last):
  File "/usr/lib/python2.7/unittest/case.py", line 312, in run
    self.setUp()
  File "/home/otto/tarmac-builds/desktopcouch/trunk/desktopcouch/application/migration/tests/test_migration.py", line 105, in setUp
    super(TestMigration, self).setUp()
  File "/home/otto/tarmac-builds/desktopcouch/trunk/desktopcouch/application/migration/tests/test_migration.py", line 57, in setUp
    self.database = DesktopDatabase(self.dbname, create=True, ctx=self.ctx)
  File "/home/otto/tarmac-builds/desktopcouch/trunk/desktopcouch/application/server.py", line 75, in __init__
    oauth_tokens=oauth_tokens, ctx=ctx, views_factory=views_factory)
  File "/home/otto/tarmac-builds/desktopcouch/trunk/desktopcouch/records/database.py", line 123, in __init__
    self._reconnect()
  File "/home/otto/tarmac-builds/desktopcouch/trunk/desktopcouch/application/server.py", l...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'desktopcouch/application/service.py'
--- desktopcouch/application/service.py 2011-04-13 21:31:15 +0000
+++ desktopcouch/application/service.py 2011-04-25 16:47:54 +0000
@@ -146,14 +146,15 @@
146146
147 def start(self):147 def start(self):
148 """Start the services used by desktopcouch."""148 """Start the services used by desktopcouch."""
149 should_shut_down_couchdb = False149 maintained_child_pids = list()
150 couchdb_pid = self._pid_finder(start_if_not_running=False,150 couchdb_pid = self._pid_finder(start_if_not_running=False,
151 ctx=self._ctx)151 ctx=self._ctx)
152 if couchdb_pid is None:152 if couchdb_pid is None:
153 logging.warn("Starting up personal couchdb.")153 logging.warn("Starting up personal couchdb.")
154 couchdb_pid = self._pid_finder(start_if_not_running=True,154 couchdb_pid = self._pid_finder(start_if_not_running=True,
155 ctx=self._ctx)155 ctx=self._ctx)
156 should_shut_down_couchdb = True156 if couchdb_pid:
157 maintained_child_pids.append(couchdb_pid)
157 else:158 else:
158 logging.warn("Personal couchdb is already running at PID#%d.",159 logging.warn("Personal couchdb is already running at PID#%d.",
159 couchdb_pid)160 couchdb_pid)
@@ -168,6 +169,7 @@
168 return169 return
169 else:170 else:
170 assert child_pid > 0171 assert child_pid > 0
172 maintained_child_pids.append(child_pid)
171 child_pid = self._fork() # Split!173 child_pid = self._fork() # Split!
172 if child_pid == 0:174 if child_pid == 0:
173 # Let's be the migration tool!175 # Let's be the migration tool!
@@ -184,8 +186,18 @@
184 return186 return
185 else:187 else:
186 assert child_pid > 0188 assert child_pid > 0
189 maintained_child_pids.append(child_pid)
187 # Let's be the dbus server!190 # Let's be the dbus server!
188 # This is the parent process. When we exit, we kill children.191 # This is the parent process. When we exit, we kill children.
192
193 def receive_signal(signum, stackframe):
194 """On signal, quit main loop gracefully."""
195 logging.warn("Received signal %d. Quitting.", signum)
196 self._mainloop.stop()
197
198 signal.signal(signal.SIGHUP, receive_signal)
199 signal.signal(signal.SIGTERM, receive_signal)
200
189 try:201 try:
190 set_up_logging("dbus")202 set_up_logging("dbus")
191 # offer the dbus service203 # offer the dbus service
@@ -195,14 +207,19 @@
195 "uncaught exception makes us shut down.")207 "uncaught exception makes us shut down.")
196 finally:208 finally:
197 logging.info("exiting.")209 logging.info("exiting.")
198 if should_shut_down_couchdb:210 self._stop_couchdb(ctx=self._ctx)
199 logging.warn("shutting down personal couchdb.")
200 self._stop_couchdb(ctx=self._ctx)
201211
212 for child_pid in maintained_child_pids:
202 try:213 try:
203 self._kill(child_pid, signal.SIGTERM)214 self._kill(child_pid, signal.SIGTERM)
204 self._sleep(1)215 logging.warn("Sent SIGTERM to %d", child_pid)
216 except OSError:
217 pass
218 self._sleep(1)
219 for child_pid in maintained_child_pids:
220 try:
205 self._kill(child_pid, signal.SIGKILL)221 self._kill(child_pid, signal.SIGKILL)
222 logging.warn("Sent SIGKILL to %d", child_pid)
206 except OSError:223 except OSError:
207 pass224 pass
208 return # pylint: disable=W0150225 return # pylint: disable=W0150
209226
=== modified file 'desktopcouch/application/tests/test_service.py'
--- desktopcouch/application/tests/test_service.py 2011-04-13 21:31:15 +0000
+++ desktopcouch/application/tests/test_service.py 2011-04-25 16:47:54 +0000
@@ -72,7 +72,7 @@
72 self._fork()72 self._fork()
73 self.mocker.result(234) # We are parent73 self.mocker.result(234) # We are parent
74 self._fork()74 self._fork()
75 self.mocker.result(234) # We are parent75 self.mocker.result(345) # We are parent
7676
77 # plugins load77 # plugins load
78 semaphores = self.mocker.mock()78 semaphores = self.mocker.mock()
@@ -121,9 +121,13 @@
121 # and then dbus service is ready to answer queries.121 # and then dbus service is ready to answer queries.
122122
123 self._stop_couchdb(ctx=self._ctx)123 self._stop_couchdb(ctx=self._ctx)
124 self._kill(self._pid_result, signal.SIGTERM)
124 self._kill(234, signal.SIGTERM)125 self._kill(234, signal.SIGTERM)
126 self._kill(345, signal.SIGTERM)
125 self._sleep(1)127 self._sleep(1)
128 self._kill(self._pid_result, signal.SIGKILL)
126 self._kill(234, signal.SIGKILL)129 self._kill(234, signal.SIGKILL)
130 self._kill(345, signal.SIGKILL)
127131
128 self.mocker.replay()132 self.mocker.replay()
129133

Subscribers

People subscribed via source and target branches