Skip to content

Commit

Permalink
Add spawn to process
Browse files Browse the repository at this point in the history
  • Loading branch information
coretl committed Jun 3, 2016
1 parent 91d591f commit d9c4c97
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions malcolm/core/process.py
Expand Up @@ -84,3 +84,10 @@ def create_queue(self):
"""

return self.sync_factory.create_queue()

def spawn(self, function, *args, **kwargs):
"""Calls SyncFactory.spawn()"""
spawned = self.sync_factory.spawn(function, *args, **kwargs)
self._other_spawned.append(spawned)
return spawned

8 changes: 8 additions & 0 deletions tests/test_core/test_process.py
Expand Up @@ -51,5 +51,13 @@ def test_error(self):
p.log_exception.assert_called_once_with("Exception while handling %s",
"<to_dict>")

def test_spawned_adds_to_other_spawned(self):
s = MagicMock()
p = Process("proc", s)
spawned = p.spawn(callable, "fred", a=4)
self.assertEqual(spawned, s.spawn.return_value)
self.assertEqual(p._other_spawned, [spawned])
s.spawn.assert_called_once_with(callable, "fred", a=4)

if __name__ == "__main__":
unittest.main(verbosity=2)

0 comments on commit d9c4c97

Please sign in to comment.