In my [Bottle](https://bottlepy.org) app running on [pythonanywhere](https://pythonanywhere.com), I want objects to be persisted between requests.

If I write something like this:

```
X = {'count': 0}

@route('/count')
def count():
    X['count'] += 1
    tpl = SimpleTemplate('Hello {{count}}!')
    return tpl.render(count=X['count'])

```

The count increments, meaning that X persists between requests.

I am currently running this on [pythonanywhere](https://pythonanywhere.com), which is a managed service where I have no control over the web server (nginx I presume?) threading, load balancing (if any) etc... 

My question is, is this coincidence because it's only using one thread while on minimal load from me doing my tests?

More generally, at which point will this stop working? E.g. I have more than one thread/socket/instance/load-balanced server etc...?

Beyond that, what is my best options to make something like this work (sticking to Bottle) even if I have to move to a barebones server.

Here's what [Bottle docs](http://bottlepy.org/docs/dev/api.html#bottle.request) have to say about their **request** object:

> 
> A thread-safe instance of LocalRequest. If accessed from within a request callback, this instance always refers to the current request (even on a multi-threaded server).
> 
> 
> 

But I don't fully understand what that means, or where global variables like the one I used stand with regards to multi-threading.