Merge pull request #1314 from minrk/spawner.start-doc

update spawner.start docs
This commit is contained in:
Carol Willing
2017-08-06 08:58:49 -07:00
committed by GitHub

View File

@@ -36,8 +36,7 @@ Some examples include:
Information about the user can be retrieved from `self.user`, Information about the user can be retrieved from `self.user`,
an object encapsulating the user's name, authentication, and server info. an object encapsulating the user's name, authentication, and server info.
When `Spawner.start` returns, it should have stored the IP and port The return value of `Spawner.start` should be the (ip, port) of the running server.
of the single-user server in `self.user.server`.
**NOTE:** When writing coroutines, *never* `yield` in between a database change and a commit. **NOTE:** When writing coroutines, *never* `yield` in between a database change and a commit.
@@ -45,10 +44,10 @@ Most `Spawner.start` functions will look similar to this example:
```python ```python
def start(self): def start(self):
self.user.server.ip = 'localhost' # or other host or IP address, as seen by the Hub self.ip = '127.0.0.1'
self.user.server.port = 1234 # port selected somehow self.port = random_port()
self.db.commit() # always commit before yield, if modifying db values
yield self._actually_start_server_somehow() yield self._actually_start_server_somehow()
return (self.ip, self.port)
``` ```
When `Spawner.start` returns, the single-user server process should actually be running, When `Spawner.start` returns, the single-user server process should actually be running,