This does not actually work. When I call this:

order = Order.get(order_id)

All the person and product info is already being acquired from the server, so I don't need to do anything more.

Another idea I had was, overriding the databaseGet and databaseSet methods from the object to make them threaded. But maybe this has too many consequenses for the rest of the code as in when I insert an object threaded it has to wait for the thread to finish before it can get the new id...

It would maybe be smarter to use a intermediate thread-launcher- object, but currently my interface is directly bound to the SQLObjects, and that is very nice!

So maybe just make the UPDATE and SELECT functions from within the sqlobject threaded?

On 12-jan-2006, at 17:16, Randall Smith wrote:

That's a neat idea. If each of (Person, Employee, Products, StockInfo) is directly related to Order (not dependent on each other), that should work. I'm interested to see you implement this.

Maybe like this:

# This code is untested and probably riddled with errors. Just hashing out an idea.

class TPerson(Thread):
    def __init__(self, person_id):
        self.person_id = person_id
    def run(self):
        person = Person.get(self.person_id)
        order_lock.acquire()
        order_data['person']
        order_lock.release()

class TProduct(Thread):
    def __init__(self, order):
        self.order = order
    def run(self):
        products = list(order.products)
        order_lock.acquire()
        order_data['products'] = products
        order_lock.release()

# Where your final data will reside.
order_data = {}

order = Order.get(order_id)
TPerson().start(order.person_id)
TProduct().start(order)
# Same for Employee and StockInfo
# However, since StockInfo probably relies on Product, you might have to spawn a TStockInfo thread from the TProduct thread.

While len(order_data) < 4:
    time.sleep(.05)

# Got the data.  Work with order_data

Good luck!

Randall

Koen Bok wrote:
Thanks Randal.
We reviewed that option, but adding an server-side rpc would mean add another point of failure. And the performance already pretty good. I work with cacheValues = True. I made my own methods to check if an object needs updating based on the sql now() function. In overall this already works really well. The only thing is when I get an order sqlobject needs:
- The order
- A person
- An employee
- The products as a list
- Stock info for the selected product
It now works linear in the above order.
But it would be faster if it worked like this:
|-------------------------------------------------------------------- -------| | THE ORDER | |-------------------------------------------------------------------- -------| | THREAD 1 | THREAD 2 | THREAD 3 | THREAD 4 | |-------------------------------------------------------------------- -------| | Employee | Person | Products | Stock | |-------------------------------------------------------------------- -------| | DONE | |-------------------------------------------------------------------- -------| So it gets all the data simultaneously. Is that achievable with sqlobject?



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to