[Zope-dev] ZODB, Threads and Persistence
Hi. Reading from Jims 'Introduction to the Zope Database': "An object's state may be freed at any time by the ZODB to conserve memory usage." What does this mean? That the object can be freed even though there are references to it? The reason I'm asking is becase I want to use threads and persistence together. I would like to inherit both threading.Thread and Persistence.Persistent, but that gives an error. I guess thats because of the ExtentionClass. However, if i only inherit Persistence.Persistent and starts a thread using the thread module withing the persistent class, what will happen with it? Can the ZODB still decide to free my persistent object even thoght it has a reference to a thread that is running?? Or can I start my thread when the object first is used, and rely on that it will be running until I stop it or remove any reference to it? /Magnus ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] ZODB, Threads and Persistence
AFAIK, you should be able to spawn a new thread from within any function within Zope and manipulate stuff in the ZODB as long as you lock properly. The number of database connections is fixed, but arbitrary threads can take up a database connection on an ad-hoc basis. If I were you, I'd mess around a little bit by spawning threads within a Product, and causing the thread to manipulate ZODB objects, keeping locking in mind. I've done this on a limited basis and it seems to work. Specifically, an object may be "ghosted" if it hasn't been accessed in a while. That doesn't mean its state goes away, it just means that it needs to reload its state when it's accessed again. Your manipulation of the object in a separate thread should prevent the object from being ghosted. - Original Message - From: "Magnus Heino (Rivermen)" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, November 10, 2000 10:35 AM Subject: [Zope-dev] ZODB, Threads and Persistence Hi. Reading from Jims 'Introduction to the Zope Database': "An object's state may be freed at any time by the ZODB to conserve memory usage." What does this mean? That the object can be freed even though there are references to it? The reason I'm asking is becase I want to use threads and persistence together. I would like to inherit both threading.Thread and Persistence.Persistent, but that gives an error. I guess thats because of the ExtentionClass. However, if i only inherit Persistence.Persistent and starts a thread using the thread module withing the persistent class, what will happen with it? Can the ZODB still decide to free my persistent object even thoght it has a reference to a thread that is running?? Or can I start my thread when the object first is used, and rely on that it will be running until I stop it or remove any reference to it? /Magnus ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope ) ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] ZODB, Threads and Persistence
AFAIK, you should be able to spawn a new thread from within any function within Zope and manipulate stuff in the ZODB as long as you lock properly. I guess I wasn't clear enough, but my application isnt within zope, im just using zodb and some more components out of it. Specifically, an object may be "ghosted" if it hasn't been accessed in a while. That doesn't mean its state goes away, it just means that it needs to reload its state when it's accessed again. Your manipulation of the object in a separate thread should prevent the object from being ghosted. But I guess this still will be the same anyway. That is, if an object inhereted from Persistence.Persistance spawns a thread that manipulated data in the object, I will have no problems. The thread will be running just fine, and the data will be stored in the zodb. ? /Magnus - Original Message - From: "Magnus Heino (Rivermen)" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, November 10, 2000 10:35 AM Subject: [Zope-dev] ZODB, Threads and Persistence Hi. Reading from Jims 'Introduction to the Zope Database': "An object's state may be freed at any time by the ZODB to conserve memory usage." What does this mean? That the object can be freed even though there are references to it? The reason I'm asking is becase I want to use threads and persistence together. I would like to inherit both threading.Thread and Persistence.Persistent, but that gives an error. I guess thats because of the ExtentionClass. However, if i only inherit Persistence.Persistent and starts a thread using the thread module withing the persistent class, what will happen with it? Can the ZODB still decide to free my persistent object even thoght it has a reference to a thread that is running?? Or can I start my thread when the object first is used, and rely on that it will be running until I stop it or remove any reference to it? /Magnus ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope ) -- /Magnus Heino ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] ZODB, Threads and Persistence
But I guess this still will be the same anyway. That is, if an object inhereted from Persistence.Persistance spawns a thread that manipulated data in the object, I will have no problems. The thread will be running just fine, and the data will be stored in the zodb. This is how I've experienced it. :-) ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )