Skip to content

Document that connections aren't thread safe in Python #897

Closed

Description

@coffeemug

From rethinkdb/rethinkdb#2427 (comment):

As far as I can tell it is not well documented that thread safety isn't guaranteed, here are the docs I've learned most of the driver stuff from and it never mentions this:

https://rethinkdb.com/docs/guide/python/
https://rethinkdb.com/docs/cookbook/python/

Even here it doesn't mention it under connect: https://rethinkdb.com/api/python/ but does mention it under repl.

Activity

  1. chipotle commented on Sep 15, 2015

    @chipotle
    Contributor

    I"m not sure whether the 10-Minute Guide is the appropriate place for it given that it's sort of a quick ReQL tutorial, although mentioning it in passing and linking to a more detailed page might fit. The cookbook definitely doesn't seem like the right place, though. Adding it to the connect page seems like a good idea.

    I'd actually think the "primary page" for this info -- which admittedly doesn't have it right now -- would be the "Installing the Python driver" page.

    http://www.rethinkdb.com/docs/install-drivers/python/

    With JS I think this is irrelevant, but is the Ruby driver subject to a similar limitation?

  2. self-assigned this
    on Sep 15, 2015
  3. sontek commented on Sep 15, 2015

    @sontek

    I would argue that any place that is the jumping off point for working with the driver it should mention this. There is a good chance someone never comes back to the API documentation if the 10-minute guide teaches them everything they need.

    The information people learn in these getting started guides could be the information they use to jump off and integrate it with their web framework. Maybe there should be a "Using RethinkDB on the web" guide that talks more about the issue?

    Most of the intro guides don't even show you need to close the connection which could be another issue when people start using this for something more meaningful like a long running application

  4. chipotle commented on Sep 15, 2015

    @chipotle
    Contributor

    The problem is defining just what the "jumping off point" is. I don't think anyone is going to be able to write a ReQL application just with the 10-minute guide, for instance; it's written to be used interactively and warns you explicitly not to use repl in production code. I would rather put the thread issue on the Python driver installation page, which users should see before this.

    Sometimes it's more a matter of figuring out where the information goes and how to highlight it. For instance, the dcoumentation for connect actually does mention that the driver is not thread-safe, and it even links to rethinkdb/rethinkdb#2427. (You do have to go to the API page for connect, not just the index page.) I will put that in a more highlighted box.

  5. sontek commented on Sep 15, 2015

    @sontek

    @chipotle Yeah, I see what you are saying. If there are some type of analytics behind the scenes that you can look at to see which pages are most popular that might give you a good sense of where to place the information.

    My work flow went like this:

    1. pip install rethinkdb
    2. Go through 10 minute guide
    3. Start writing my application, find errors, search and land on the cookbook
    4. Have the driver start blowing up in random ways because I'm using threads.

    So the pages I had landed on from an SEO standpoint wee:

    https://rethinkdb.com/api/python/
    https://rethinkdb.com/docs/cookbook/python/
    https://www.rethinkdb.com/docs/guide/python/

    and from those I never had to look at the documentation again because I had a decent understanding of the framework and good use my repl from there:

    In [1]: import rethinkdb as r
    
    In [2]: r.connect??
    Type:        function
    String form: <function connect at 0x7f35b9153c80>
    File:        /home/sontek/venvs/rethinkdb/src/rethinkdb/drivers/python/rethinkdb/net.py
    Definition:  r.connect(host='localhost', port=28015, db=None, auth_key='', timeout=20, ssl={}, **kwargs)
    Source:
    def connect(host='localhost', port=28015, db=None, auth_key="", timeout=20, ssl=dict(), **kwargs):
        global connection_type
        conn = connection_type(host, port, db, auth_key, timeout, ssl, **kwargs)
        return conn.reconnect(timeout=timeout)

    But as you can see here, even the docstring of connect doesn't mention that it isn't threadsafe. So I want to make sure thats its mentioned in an area that is practical and will actually be viewed by most people. Even if it doesn't strike us as the right place to put it.

    I'm willing to admit that my path to this may have been the non-common path though, I'm just providing some anecdotal evidence

  6. chipotle commented on Sep 15, 2015

    @chipotle
    Contributor

    It's good to know! We're probably going to add a little note about the lack of thread safety at the very bottom of the 10-minute guide under the "Learn more" box, as well as the driver installation page, so hopefully people will be able to find this. (I'm also going to add notes about the integration with Tornado there, with links to the main documentation on how that works.)

  7. added a commit that references this issue on Oct 9, 2015
    e6c15c9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions