access/update global/shared defaultdict from different tornado.RequestHandler instances
<p>Is it safe to access/update a global <code>defaultdict</code> from different <code>RequestHandler</code> instances? E.g.</p>

<pre><code>GlobalMap = defaultdict(list)

class Event(tornado.web.RequestHandler):
    def get(self, unit):
        # This is where the access/modify might happen
        # The list.append() is just an arbitrary example
        GlobalMap[unit].append(datetime.utcnow()) 
        self.write(b'') 
</code></pre>

<p>If not, whatâs the proper way to do a lookup/store of keyed data between different <code>RequestHandler</code> instances?</p>

<p>Yes, that's fine to do. Tornado code typically runs in the main thread; any code that accesses a Python data structure like this.</p>

<p>However, if you're deploying a Tornado application in production you'll want multiple Tornado processes, maybe running on multiple machines, so you'll want to put data in a shared database server to share it among processes.</p>

python python-3.x tornado defaultdict