Shared object between requests in Django

后端 未结 3 428
臣服心动
臣服心动 2020-12-19 21:06

I am using a Python module (PyCLIPS) and Django 1.3.

I want develop a thread-safety class which realizes the Object Pool and the Singleton patterns and also that hav

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-19 22:02

    Are these database objects? Because if so, the db itself is really the pool, and there's no need to do anything special - each request can independently load the instance from the db, modify it, and save it back.

    Edit after comment Well, the biggest problem is that a production web server environment is likely to be multi-process, so any global variables (ie the pool) are not shared between processes. You will need to store them somewhere that's globally accessible. A short in the dark, but are they serializable using Pickle? If so, then perhaps memcache might work.

提交回复
热议问题