I can change the name. The problem is that if the app is accessed while you are doing this, the object has to be mutex locked. That is why this is not exposed. it is not thread safe.
Massimo On Mar 13, 3:58 pm, Yarko Tymciurak <yark...@gmail.com> wrote: > On Fri, Mar 13, 2009 at 8:58 AM, DenesL <denes1...@yahoo.ca> wrote: > > > On Mar 13, 8:27 am, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > They are listed in > > > > SQLDB._instances[thread.id] > > > > Look into SQLDB._close_all_instances in sql.py > > > I know there is class SQLDB in gluon.sql, but what is this SQLDB > > object? > > DenesL - sounds like you need to get yourself 2 things: ipython (really! > will help much) e.g.: > > > > > In [3]: d={'a':1,'b':2} > > >> In [4]: d > > > Out[4]: {'a': 1, 'b': 2} > > >> In [5]: d. [type a tab to get completion, and see result below:] > > > d.__class__ d.__gt__ d.__reduce_ex__ d.items > > > d.__cmp__ d.__hash__ d.__repr__ d.iteritems > > > d.__contains__ d.__init__ d.__setattr__ d.iterkeys > > > d.__delattr__ d.__iter__ d.__setitem__ d.itervalues > > > d.__delitem__ d.__le__ d.__str__ d.keys > > > d.__doc__ d.__len__ d.clear d.pop > > > d.__eq__ d.__lt__ d.copy d.popitem > > > d.__ge__ d.__ne__ d.fromkeys d.setdefault > > > d.__getattribute__ d.__new__ d.get d.update > > > d.__getitem__ d.__reduce__ d.has_key d.values > > Then the second thing you might want to get - WingIDE (are you coming to > PyCon? Wingware is giving away pro licenses to anyone who participates in a > sprint;) --- Probably Eclipse would help here equivalently, but I didn't > have too much happiness using eclipse w/ python (so I use Wing)... > > Look at gluon/sql.py, class SQLDB(SQLStorage) > > _instances={} > > > And, furthermore, if I have db1, db2, ... > > len(SQLDB._instances) == 1 (???) > > I think the naming is unfortunate here. It is completely reasonable to read > "SQLDB._instances" and expect you are looking at the number of database > instances. Unfortunately, this is not what this gives you. > > This says you have only one SQLDB thread. You want to look at the number > of connections that thread has, e.g. > > In [21]: SQLDB._instances.keys() > Out[21]: [4208] > > In [22]: len(SQLDB._instances[4208]) > Out[22]: 2 > > So you want something like: > > In [25]: for instance in SQLDB._instances.keys(): > ....: len(SQLDB._instances[instance]) > ....: pass > ....: > Out[25]: 2 > > A better choice of name for this would maybe be: SQLDB._threads > > Then you would be reading things like: > > len(SQLDB._threads.keys()) to say "how many threads have open databases? > (which reads correctly) > and len(SQLDB_treads[thread_n]) to say "how many open databases does > thread_n have? > > and len(db2._threads.keys()) to say "how many threads have db2 open? > > I'll talk with Massimo about renaming this. As it is, it's an "internal" > (underscore) variable, so backward compatibility should not be an issue. > There's already a _threads list in wsgiserver, and this is a dict (you can > return the SQLDB objects for a thread... > > I think we can find some name that makes this clear. > > In the meantime, I hope this helps. > > Regards, > Yarko > > P.S. --- I think I like this name; see what you think: > > In [25]: for thread in SQLDB._by_thread.keys(): > ....: len(SQLDB._by_thread[thread]) > ....: pass > ....: > Out[25]: 2 > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---