[web2py] Re: Standalone DAL leaves mysql connections opened

2012-07-18 Thread Phyo Arkar

I am also having same problem , web2py DAL do not close connection and 
fails after too many connection on mysql opened.

I do not have any problem before versions 1.99.1 or 1.99.2 . is that new 
bug introduced after 1.99.4 ?

coz we are happening at 1.99.4 and up.

On Friday, June 22, 2012 10:53:47 PM UTC+6:30, demetrio wrote:


 Hi everyone,

 I have connected WebDAV and SVN auth with a wsgi script. I needed to use a 
 standalone DAL. When you do a dav petition with the navigator it makes a 
 lot of petitions. Well, the thing is that always there is a connection 
 opened (i can see them with PhpMyAdmin)

 if self.db: 
 self.db._adapter.close()

 seeing this issue: 
 http://code.google.com/p/web2py/issues/detail?id=731http://code.google.com/p/web2py/issues/detail?id=731#c4

 I have tried a lot of the lines that i found there

 something like:

 if self.db:
 from gluon.dal import BaseAdapter
 BaseAdapter.close_all_instances(None)
 BaseAdapter.close_all_instances('commit')
 BaseAdapter.close_all_instances('rollback')

 something like:
 if self.db:
 from gluon.dal import thread as dal_thread
 dal_thread.instances.remove(self.db._adapter)
 self.db._adapter.close()

 and even something desesperated like:
 if self.db:
 from gluon.dal import thread as dal_thread
 dal_thread.instances.remove(self.db._adapter)
 self.db._adapter.close()
 self.db._adapter.close_all_instances(None)
 self.db._adapter.close_all_instances('commit')
 self.db._adapter.close_all_instances('rollback')

 from gluon.dal import ConnectionPool
 ConnectionPool.close_all_instances(None)
 ConnectionPool.close_all_instances('commit')
 ConnectionPool.close_all_instances('rollback')
 
 from gluon.dal import BaseAdapter
 BaseAdapter.close_all_instances(None)
 BaseAdapter.close_all_instances('commit')
 BaseAdapter.close_all_instances('rollback')

 But always, in the best, it leaves at least one connection opened, and i 
 don't know how to deal with it.

 I have using web2py 1.99.7 in both development and production environments.

 Any ideas? in this moment we are building a python mysql script, but we 
 want to use DAL to make it runnable on any of the web2py/DAL supported db

 Thanks in advance


-- 





Re: [web2py] Re: Standalone DAL leaves mysql connections opened

2012-07-09 Thread Daniel González Zaballos
No (or at least not me), the many connections are from the web 
navigator, that send many get / options or propfind requests for 
dav/svn, when i try only one time to access. Its the same if I use a dav 
or svn client, and with the file explorer included in the application 
they send many request.


I suposse that apache opens a thread in each request.

But with a direct mysql connection (using the mysql library included in 
gluon) we can close all the connections without problems.



El 08/07/12 00:06, Massimo Di Pierro escribió:

Are you using threads?

On Saturday, July 7, 2012 9:21:51 AM UTC-5, demetrio wrote:

It's not working :(

In the best scenario i can leave one connection opened in a whole
request (with other combinations it leaves at least 10 more or less)
only with:

self.db.commit()
from gluon.dal import BaseAdapter
BaseAdapter.close_all_instances('commit')



2012/7/7 Daniel Gonzale dgzabal...@gmail.com
mailto:dgzabal...@gmail.com:
 Of course, i will try this afternoon.



 El 07/07/2012, a las 03:33, Massimo Di Pierro
massimo.dipie...@gmail.com mailto:massimo.dipie...@gmail.com
 escribió:

 Meanwhile, can you check the new db.close() in trunk?

 On Friday, 6 July 2012 15:40:57 UTC-5, demetrio wrote:

 Mail with the code sended :)

 2012/7/6 Massimo Di Pierro massimo.dipie...@gmail.com
mailto:massimo.dipie...@gmail.com:
  I do not recall. Can you resend it please. My personal inbox
is a bit
  messy.
 
 
  On Friday, 6 July 2012 05:51:04 UTC-5, demetrio wrote:
 
  I will try this weekend.
 
  Massimo did you received the code of the apllication?
 
  Thanks everyone
 
 
 
  El 06/07/2012, a las 04:32, Massimo Di Pierro
  massimo.dipie...@gmail.com
mailto:massimo.dipie...@gmail.com
  escribió:
 
  Looks like I prematurely close the issue. There is now a
db.close() in
  trunk. Please check it out.
 
  massimo
 
  On Thursday, 5 July 2012 13:05:47 UTC-5, nick name wrote:
 
  On Thursday, June 28, 2012 10:47:15 AM UTC-4, Massimo Di
Pierro wrote:
 
  why not simply?
 
  db.commit()
  db.close()
 
  if db in an on object attribute like self.db you can do
 
  if self.db:
 self.db.commit()
 self.db.close()
 self.db = 0
 
  you can also do:
 
  BaseAdapter.close_all_instances('commit')
 
 
  This is not enough, as was documented on issue
  http://code.google.com/p/web2py/issues/detail?id=731
http://code.google.com/p/web2py/issues/detail?id=731. The code that
  works
  for me for sqlite is as follows:
 
  def closebase(base):
  if not base: return
  # see:
http://code.google.com/p/web2py/issues/detail?id=731
http://code.google.com/p/web2py/issues/detail?id=731
  # see:
 
https://groups.google.com/d/topic/web2py/hmsupVHdDHo/discussion
https://groups.google.com/d/topic/web2py/hmsupVHdDHo/discussion
  # was: base._adapter.close()
  from gluon.dal import thread
  thread.instances.remove(base._adapter)
  base._adapter.close()
 
  and then I call closebase(db); db = None which is enough
for me with
  sqlite -- but apparently, the original poster has tried
that, and that
  is
  not sufficient for mysql.






Re: [web2py] Re: Standalone DAL leaves mysql connections opened

2012-07-07 Thread Daniel Gonzale
Of course, i will try this afternoon.



El 07/07/2012, a las 03:33, Massimo Di Pierro massimo.dipie...@gmail.com 
escribió:

 Meanwhile, can you check the new db.close() in trunk?
 
 On Friday, 6 July 2012 15:40:57 UTC-5, demetrio wrote:
 Mail with the code sended :) 
 
 2012/7/6 Massimo Di Pierro massimo.dipie...@gmail.com: 
  I do not recall. Can you resend it please. My personal inbox is a bit 
  messy. 
  
  
  On Friday, 6 July 2012 05:51:04 UTC-5, demetrio wrote: 
  
  I will try this weekend. 
  
  Massimo did you received the code of the apllication? 
  
  Thanks everyone 
  
  
  
  El 06/07/2012, a las 04:32, Massimo Di Pierro massimo.dipie...@gmail.com 
  escribió: 
  
  Looks like I prematurely close the issue. There is now a db.close() in 
  trunk. Please check it out. 
  
  massimo 
  
  On Thursday, 5 July 2012 13:05:47 UTC-5, nick name wrote: 
  
  On Thursday, June 28, 2012 10:47:15 AM UTC-4, Massimo Di Pierro wrote: 
  
  why not simply? 
  
  db.commit() 
  db.close() 
  
  if db in an on object attribute like self.db you can do 
  
  if self.db: 
 self.db.commit() 
 self.db.close() 
 self.db = 0 
  
  you can also do: 
  
  BaseAdapter.close_all_instances('commit') 
  
  
  This is not enough, as was documented on issue 
  http://code.google.com/p/web2py/issues/detail?id=731. The code that works 
  for me for sqlite is as follows: 
  
  def closebase(base): 
  if not base: return 
  # see: http://code.google.com/p/web2py/issues/detail?id=731 
  # see: 
  https://groups.google.com/d/topic/web2py/hmsupVHdDHo/discussion 
  # was: base._adapter.close() 
  from gluon.dal import thread 
  thread.instances.remove(base._adapter) 
  base._adapter.close() 
  
  and then I call closebase(db); db = None which is enough for me with 
  sqlite -- but apparently, the original poster has tried that, and that is 
  not sufficient for mysql. 


Re: [web2py] Re: Standalone DAL leaves mysql connections opened

2012-07-07 Thread Daniel Gonzalez Zaballos
It's not working :(

In the best scenario i can leave one connection opened in a whole
request (with other combinations it leaves at least 10 more or less)
only with:

self.db.commit()
from gluon.dal import BaseAdapter
BaseAdapter.close_all_instances('commit')



2012/7/7 Daniel Gonzale dgzabal...@gmail.com:
 Of course, i will try this afternoon.



 El 07/07/2012, a las 03:33, Massimo Di Pierro massimo.dipie...@gmail.com
 escribió:

 Meanwhile, can you check the new db.close() in trunk?

 On Friday, 6 July 2012 15:40:57 UTC-5, demetrio wrote:

 Mail with the code sended :)

 2012/7/6 Massimo Di Pierro massimo.dipie...@gmail.com:
  I do not recall. Can you resend it please. My personal inbox is a bit
  messy.
 
 
  On Friday, 6 July 2012 05:51:04 UTC-5, demetrio wrote:
 
  I will try this weekend.
 
  Massimo did you received the code of the apllication?
 
  Thanks everyone
 
 
 
  El 06/07/2012, a las 04:32, Massimo Di Pierro
  massimo.dipie...@gmail.com
  escribió:
 
  Looks like I prematurely close the issue. There is now a db.close() in
  trunk. Please check it out.
 
  massimo
 
  On Thursday, 5 July 2012 13:05:47 UTC-5, nick name wrote:
 
  On Thursday, June 28, 2012 10:47:15 AM UTC-4, Massimo Di Pierro wrote:
 
  why not simply?
 
  db.commit()
  db.close()
 
  if db in an on object attribute like self.db you can do
 
  if self.db:
 self.db.commit()
 self.db.close()
 self.db = 0
 
  you can also do:
 
  BaseAdapter.close_all_instances('commit')
 
 
  This is not enough, as was documented on issue
  http://code.google.com/p/web2py/issues/detail?id=731. The code that
  works
  for me for sqlite is as follows:
 
  def closebase(base):
  if not base: return
  # see: http://code.google.com/p/web2py/issues/detail?id=731
  # see:
  https://groups.google.com/d/topic/web2py/hmsupVHdDHo/discussion
  # was: base._adapter.close()
  from gluon.dal import thread
  thread.instances.remove(base._adapter)
  base._adapter.close()
 
  and then I call closebase(db); db = None which is enough for me with
  sqlite -- but apparently, the original poster has tried that, and that
  is
  not sufficient for mysql.


Re: [web2py] Re: Standalone DAL leaves mysql connections opened

2012-07-07 Thread Massimo Di Pierro
Are you using threads?

On Saturday, July 7, 2012 9:21:51 AM UTC-5, demetrio wrote:

 It's not working :( 

 In the best scenario i can leave one connection opened in a whole 
 request (with other combinations it leaves at least 10 more or less) 
 only with: 

 self.db.commit() 
 from gluon.dal import BaseAdapter 
 BaseAdapter.close_all_instances('commit') 



 2012/7/7 Daniel Gonzale dgzabal...@gmail.com: 
  Of course, i will try this afternoon. 
  
  
  
  El 07/07/2012, a las 03:33, Massimo Di Pierro 
 massimo.dipie...@gmail.com 
  escribió: 
  
  Meanwhile, can you check the new db.close() in trunk? 
  
  On Friday, 6 July 2012 15:40:57 UTC-5, demetrio wrote: 
  
  Mail with the code sended :) 
  
  2012/7/6 Massimo Di Pierro massimo.dipie...@gmail.com: 
   I do not recall. Can you resend it please. My personal inbox is a bit 
   messy. 
   
   
   On Friday, 6 July 2012 05:51:04 UTC-5, demetrio wrote: 
   
   I will try this weekend. 
   
   Massimo did you received the code of the apllication? 
   
   Thanks everyone 
   
   
   
   El 06/07/2012, a las 04:32, Massimo Di Pierro 
   massimo.dipie...@gmail.com 
   escribió: 
   
   Looks like I prematurely close the issue. There is now a db.close() 
 in 
   trunk. Please check it out. 
   
   massimo 
   
   On Thursday, 5 July 2012 13:05:47 UTC-5, nick name wrote: 
   
   On Thursday, June 28, 2012 10:47:15 AM UTC-4, Massimo Di Pierro 
 wrote: 
   
   why not simply? 
   
   db.commit() 
   db.close() 
   
   if db in an on object attribute like self.db you can do 
   
   if self.db: 
  self.db.commit() 
  self.db.close() 
  self.db = 0 
   
   you can also do: 
   
   BaseAdapter.close_all_instances('commit') 
   
   
   This is not enough, as was documented on issue 
   http://code.google.com/p/web2py/issues/detail?id=731. The code 
 that 
   works 
   for me for sqlite is as follows: 
   
   def closebase(base): 
   if not base: return 
   # see: http://code.google.com/p/web2py/issues/detail?id=731 
   # see: 
   https://groups.google.com/d/topic/web2py/hmsupVHdDHo/discussion 
   # was: base._adapter.close() 
   from gluon.dal import thread 
   thread.instances.remove(base._adapter) 
   base._adapter.close() 
   
   and then I call closebase(db); db = None which is enough for me 
 with 
   sqlite -- but apparently, the original poster has tried that, and 
 that 
   is 
   not sufficient for mysql. 



Re: [web2py] Re: Standalone DAL leaves mysql connections opened

2012-07-06 Thread Daniel Gonzale
I will try this weekend.

Massimo did you received the code of the apllication?

Thanks everyone



El 06/07/2012, a las 04:32, Massimo Di Pierro massimo.dipie...@gmail.com 
escribió:

 Looks like I prematurely close the issue. There is now a db.close() in trunk. 
 Please check it out.
 
 massimo
 
 On Thursday, 5 July 2012 13:05:47 UTC-5, nick name wrote:
 On Thursday, June 28, 2012 10:47:15 AM UTC-4, Massimo Di Pierro wrote:
 why not simply?
 
 db.commit()
 db.close()
 
 if db in an on object attribute like self.db you can do
 
 if self.db:
self.db.commit()
self.db.close()
self.db = 0
 
 you can also do:
 
 BaseAdapter.close_all_instances('commit')
 
 This is not enough, as was documented on issue  
 http://code.google.com/p/web2py/issues/detail?id=731. The code that works for 
 me for sqlite is as follows:
 
 def closebase(base):
 if not base: return
 # see: http://code.google.com/p/web2py/issues/detail?id=731
 # see: https://groups.google.com/d/topic/web2py/hmsupVHdDHo/discussion
 # was: base._adapter.close()
 from gluon.dal import thread
 thread.instances.remove(base._adapter)
 base._adapter.close()
 
 and then I call closebase(db); db = None which is enough for me with sqlite 
 -- but apparently, the original poster has tried that, and that is not 
 sufficient for mysql.


Re: [web2py] Re: Standalone DAL leaves mysql connections opened

2012-07-06 Thread Massimo Di Pierro
I do not recall. Can you resend it please. My personal inbox is a bit messy.

On Friday, 6 July 2012 05:51:04 UTC-5, demetrio wrote:

 I will try this weekend.

 Massimo did you received the code of the apllication?

 Thanks everyone



 El 06/07/2012, a las 04:32, Massimo Di Pierro massimo.dipie...@gmail.com 
 escribió:

 Looks like I prematurely close the issue. There is now a db.close() in 
 trunk. Please check it out.

 massimo

 On Thursday, 5 July 2012 13:05:47 UTC-5, nick name wrote:

 On Thursday, June 28, 2012 10:47:15 AM UTC-4, Massimo Di Pierro wrote:

 why not simply?

 db.commit()
 db.close()

 if db in an on object attribute like self.db you can do

 if self.db:
self.db.commit()
self.db.close()
self.db = 0

 you can also do:

 BaseAdapter.close_all_instances('commit')


 This is not enough, as was documented on issue  
 http://code.google.com/p/web2py/issues/detail?id=731http://code.google.com/p/web2py/issues/detail?id=731#c4.
  
 The code that works for me for sqlite is as follows:

 def closebase(base):
 if not base: return
 # see: http://code.google.com/p/web2py/issues/detail?id=731
 # see: 
 https://groups.google.com/d/topic/web2py/hmsupVHdDHo/discussion
 # was: base._adapter.close()
 from gluon.dal import thread
 thread.instances.remove(base._adapter)
 base._adapter.close()

 and then I call closebase(db); db = None which is enough for me with 
 sqlite -- but apparently, the original poster has tried that, and that is 
 not sufficient for mysql.



Re: [web2py] Re: Standalone DAL leaves mysql connections opened

2012-07-06 Thread Daniel Gonzalez Zaballos
Mail with the code sended :)

2012/7/6 Massimo Di Pierro massimo.dipie...@gmail.com:
 I do not recall. Can you resend it please. My personal inbox is a bit messy.


 On Friday, 6 July 2012 05:51:04 UTC-5, demetrio wrote:

 I will try this weekend.

 Massimo did you received the code of the apllication?

 Thanks everyone



 El 06/07/2012, a las 04:32, Massimo Di Pierro massimo.dipie...@gmail.com
 escribió:

 Looks like I prematurely close the issue. There is now a db.close() in
 trunk. Please check it out.

 massimo

 On Thursday, 5 July 2012 13:05:47 UTC-5, nick name wrote:

 On Thursday, June 28, 2012 10:47:15 AM UTC-4, Massimo Di Pierro wrote:

 why not simply?

 db.commit()
 db.close()

 if db in an on object attribute like self.db you can do

 if self.db:
self.db.commit()
self.db.close()
self.db = 0

 you can also do:

 BaseAdapter.close_all_instances('commit')


 This is not enough, as was documented on issue
 http://code.google.com/p/web2py/issues/detail?id=731. The code that works
 for me for sqlite is as follows:

 def closebase(base):
 if not base: return
 # see: http://code.google.com/p/web2py/issues/detail?id=731
 # see:
 https://groups.google.com/d/topic/web2py/hmsupVHdDHo/discussion
 # was: base._adapter.close()
 from gluon.dal import thread
 thread.instances.remove(base._adapter)
 base._adapter.close()

 and then I call closebase(db); db = None which is enough for me with
 sqlite -- but apparently, the original poster has tried that, and that is
 not sufficient for mysql.


Re: [web2py] Re: Standalone DAL leaves mysql connections opened

2012-07-06 Thread Massimo Di Pierro
Meanwhile, can you check the new db.close() in trunk?

On Friday, 6 July 2012 15:40:57 UTC-5, demetrio wrote:

 Mail with the code sended :) 

 2012/7/6 Massimo Di Pierro massimo.dipie...@gmail.com: 
  I do not recall. Can you resend it please. My personal inbox is a bit 
 messy. 
  
  
  On Friday, 6 July 2012 05:51:04 UTC-5, demetrio wrote: 
  
  I will try this weekend. 
  
  Massimo did you received the code of the apllication? 
  
  Thanks everyone 
  
  
  
  El 06/07/2012, a las 04:32, Massimo Di Pierro 
 massimo.dipie...@gmail.com 
  escribió: 
  
  Looks like I prematurely close the issue. There is now a db.close() in 
  trunk. Please check it out. 
  
  massimo 
  
  On Thursday, 5 July 2012 13:05:47 UTC-5, nick name wrote: 
  
  On Thursday, June 28, 2012 10:47:15 AM UTC-4, Massimo Di Pierro wrote: 
  
  why not simply? 
  
  db.commit() 
  db.close() 
  
  if db in an on object attribute like self.db you can do 
  
  if self.db: 
 self.db.commit() 
 self.db.close() 
 self.db = 0 
  
  you can also do: 
  
  BaseAdapter.close_all_instances('commit') 
  
  
  This is not enough, as was documented on issue 
  http://code.google.com/p/web2py/issues/detail?id=731. The code that 
 works 
  for me for sqlite is as follows: 
  
  def closebase(base): 
  if not base: return 
  # see: http://code.google.com/p/web2py/issues/detail?id=731 
  # see: 
  https://groups.google.com/d/topic/web2py/hmsupVHdDHo/discussion 
  # was: base._adapter.close() 
  from gluon.dal import thread 
  thread.instances.remove(base._adapter) 
  base._adapter.close() 
  
  and then I call closebase(db); db = None which is enough for me with 
  sqlite -- but apparently, the original poster has tried that, and that 
 is 
  not sufficient for mysql. 



[web2py] Re: Standalone DAL leaves mysql connections opened

2012-07-05 Thread nick name
On Thursday, June 28, 2012 10:47:15 AM UTC-4, Massimo Di Pierro wrote:

 why not simply?

 db.commit()
 db.close()

 if db in an on object attribute like self.db you can do

 if self.db:
self.db.commit()
self.db.close()
self.db = 0

 you can also do:

 BaseAdapter.close_all_instances('commit')


This is not enough, as was documented on issue  
http://code.google.com/p/web2py/issues/detail?id=731http://code.google.com/p/web2py/issues/detail?id=731#c4.
 
The code that works for me for sqlite is as follows:

def closebase(base):
if not base: return
# see: http://code.google.com/p/web2py/issues/detail?id=731
# see: https://groups.google.com/d/topic/web2py/hmsupVHdDHo/discussion
# was: base._adapter.close()
from gluon.dal import thread
thread.instances.remove(base._adapter)
base._adapter.close()

and then I call closebase(db); db = None which is enough for me with sqlite 
-- but apparently, the original poster has tried that, and that is not 
sufficient for mysql.


[web2py] Re: Standalone DAL leaves mysql connections opened

2012-07-05 Thread Massimo Di Pierro
Looks like I prematurely close the issue. There is now a db.close() in 
trunk. Please check it out.

massimo

On Thursday, 5 July 2012 13:05:47 UTC-5, nick name wrote:

 On Thursday, June 28, 2012 10:47:15 AM UTC-4, Massimo Di Pierro wrote:

 why not simply?

 db.commit()
 db.close()

 if db in an on object attribute like self.db you can do

 if self.db:
self.db.commit()
self.db.close()
self.db = 0

 you can also do:

 BaseAdapter.close_all_instances('commit')


 This is not enough, as was documented on issue  
 http://code.google.com/p/web2py/issues/detail?id=731http://code.google.com/p/web2py/issues/detail?id=731#c4.
  
 The code that works for me for sqlite is as follows:

 def closebase(base):
 if not base: return
 # see: http://code.google.com/p/web2py/issues/detail?id=731
 # see: https://groups.google.com/d/topic/web2py/hmsupVHdDHo/discussion
 # was: base._adapter.close()
 from gluon.dal import thread
 thread.instances.remove(base._adapter)
 base._adapter.close()

 and then I call closebase(db); db = None which is enough for me with 
 sqlite -- but apparently, the original poster has tried that, and that is 
 not sufficient for mysql.



[web2py] Re: Standalone DAL leaves mysql connections opened

2012-06-28 Thread Massimo Di Pierro
why not simply?

db.commit()
db.close()

if db in an on object attribute like self.db you can do

if self.db:
   self.db.commit()
   self.db.close()
   self.db = 0

you can also do:

BaseAdapter.close_all_instances('commit')



On Friday, 22 June 2012 11:23:47 UTC-5, demetrio wrote:


 Hi everyone,

 I have connected WebDAV and SVN auth with a wsgi script. I needed to use a 
 standalone DAL. When you do a dav petition with the navigator it makes a 
 lot of petitions. Well, the thing is that always there is a connection 
 opened (i can see them with PhpMyAdmin)

 if self.db: 
 self.db._adapter.close()

 seeing this issue: 
 http://code.google.com/p/web2py/issues/detail?id=731http://code.google.com/p/web2py/issues/detail?id=731#c4

 I have tried a lot of the lines that i found there

 something like:

 if self.db:
 from gluon.dal import BaseAdapter
 BaseAdapter.close_all_instances(None)
 BaseAdapter.close_all_instances('commit')
 BaseAdapter.close_all_instances('rollback')

 something like:
 if self.db:
 from gluon.dal import thread as dal_thread
 dal_thread.instances.remove(self.db._adapter)
 self.db._adapter.close()

 and even something desesperated like:
 if self.db:
 from gluon.dal import thread as dal_thread
 dal_thread.instances.remove(self.db._adapter)
 self.db._adapter.close()
 self.db._adapter.close_all_instances(None)
 self.db._adapter.close_all_instances('commit')
 self.db._adapter.close_all_instances('rollback')

 from gluon.dal import ConnectionPool
 ConnectionPool.close_all_instances(None)
 ConnectionPool.close_all_instances('commit')
 ConnectionPool.close_all_instances('rollback')
 
 from gluon.dal import BaseAdapter
 BaseAdapter.close_all_instances(None)
 BaseAdapter.close_all_instances('commit')
 BaseAdapter.close_all_instances('rollback')

 But always, in the best, it leaves at least one connection opened, and i 
 don't know how to deal with it.

 I have using web2py 1.99.7 in both development and production environments.

 Any ideas? in this moment we are building a python mysql script, but we 
 want to use DAL to make it runnable on any of the web2py/DAL supported db

 Thanks in advance



Re: [web2py] Re: Standalone DAL leaves mysql connections opened

2012-06-28 Thread Daniel González Zaballos

It does not work.

If I use the self.db = 0 sometimes i get this error (and connections are 
open):


mod_wsgi (pid=1419): Exception occurred processing WSGI script 
'/home/demetrio/devel/python_virtual_2.6/web2py/applications/forge2/scripts/auth.py'.

Traceback (most recent call last):
File 
/home/demetrio/devel/python_virtual_2.6/web2py/applications/forge2/scripts/auth.py, 
line 64, in check_password

close_auth(auth)
File 
/home/demetrio/devel/python_virtual_2.6/web2py/applications/forge2/scripts/base_auth.py, 
line 68, in close_auth

auth.close()
File 
/home/demetrio/devel/python_virtual_2.6/web2py/applications/forge2/scripts/base_auth.py, 
line 97, in close

self.db.close()
File /home/demetrio/devel/python_virtual_2.6/web2py/gluon/dal.py, line 
6343, in __getattr__

 return self[key]
File /home/demetrio/devel/python_virtual_2.6/web2py/gluon/dal.py, line 
6337, in __getitem__

 return dict.__getitem__(self, str(key))
 KeyError: 'close'

With BaseAdapter.close_all_instances('commit') its the same


El 28/06/12 16:47, Massimo Di Pierro escribió:

why not simply?

db.commit()
db.close()

if db in an on object attribute like self.db you can do

if self.db:
   self.db.commit()
   self.db.close()
   self.db = 0

you can also do:

BaseAdapter.close_all_instances('commit')



On Friday, 22 June 2012 11:23:47 UTC-5, demetrio wrote:


Hi everyone,

I have connected WebDAV and SVN auth with a wsgi script. I needed
to use a standalone DAL. When you do a dav petition with the
navigator it makes a lot of petitions. Well, the thing is that
always there is a connection opened (i can see them with PhpMyAdmin)

|
if self.db:
self.db._adapter.close()
|

seeing this issue:
http://code.google.com/p/web2py/issues/detail?id=731
http://code.google.com/p/web2py/issues/detail?id=731#c4

I have tried a lot of the lines that i found there

something like:

|
if self.db:
from gluon.dal import BaseAdapter
BaseAdapter.close_all_instances(None)
BaseAdapter.close_all_instances('commit')
BaseAdapter.close_all_instances('rollback')
|

something like:
|
if self.db:
from gluon.dal import thread as dal_thread
dal_thread.instances.remove(self.db._adapter)
self.db._adapter.close()
|

and even something desesperated like:
|
if self.db:
from gluon.dal import thread as dal_thread
dal_thread.instances.remove(self.db._adapter)
self.db._adapter.close()
self.db._adapter.close_all_instances(None)
self.db._adapter.close_all_instances('commit')
self.db._adapter.close_all_instances('rollback')

from gluon.dal import ConnectionPool
ConnectionPool.close_all_instances(None)
ConnectionPool.close_all_instances('commit')
ConnectionPool.close_all_instances('rollback')

from gluon.dal import BaseAdapter
BaseAdapter.close_all_instances(None)
BaseAdapter.close_all_instances('commit')
BaseAdapter.close_all_instances('rollback')
|

But always, in the best, it leaves at least one connection opened,
and i don't know how to deal with it.

I have using web2py 1.99.7 in both development and production
environments.

Any ideas? in this moment we are building a python mysql script,
but we want to use DAL to make it runnable on any of the
web2py/DAL supported db

Thanks in advance






Re: [web2py] Re: Standalone DAL leaves mysql connections opened

2012-06-28 Thread Massimo DiPierro
Can I see the code?

On Jun 28, 2012, at 10:08 AM, Daniel González Zaballos wrote:

 It does not work.
 
 If I use the self.db = 0 sometimes i get this error (and connections are 
 open):
 
 mod_wsgi (pid=1419): Exception occurred processing WSGI script 
 '/home/demetrio/devel/python_virtual_2.6/web2py/applications/forge2/scripts/auth.py'.
 Traceback (most recent call last):
 File 
 /home/demetrio/devel/python_virtual_2.6/web2py/applications/forge2/scripts/auth.py,
  line 64, in check_password
 close_auth(auth)
 File 
 /home/demetrio/devel/python_virtual_2.6/web2py/applications/forge2/scripts/base_auth.py,
  line 68, in close_auth
 auth.close()
 File 
 /home/demetrio/devel/python_virtual_2.6/web2py/applications/forge2/scripts/base_auth.py,
  line 97, in close
 self.db.close()
 File /home/demetrio/devel/python_virtual_2.6/web2py/gluon/dal.py, line 
 6343, in __getattr__
  return self[key]
 File /home/demetrio/devel/python_virtual_2.6/web2py/gluon/dal.py, line 
 6337, in __getitem__
  return dict.__getitem__(self, str(key))
  KeyError: 'close'
 
 With BaseAdapter.close_all_instances('commit') its the same
 
 
 El 28/06/12 16:47, Massimo Di Pierro escribió:
 why not simply?
 
 db.commit()
 db.close()
 
 if db in an on object attribute like self.db you can do
 
 if self.db:
self.db.commit()
self.db.close()
self.db = 0
 
 you can also do:
 
 BaseAdapter.close_all_instances('commit')
 
 
 
 On Friday, 22 June 2012 11:23:47 UTC-5, demetrio wrote:
 
 Hi everyone,
 
 I have connected WebDAV and SVN auth with a wsgi script. I needed to use a 
 standalone DAL. When you do a dav petition with the navigator it makes a lot 
 of petitions. Well, the thing is that always there is a connection opened (i 
 can see them with PhpMyAdmin)
 
 if self.db: 
 self.db._adapter.close()
 
 seeing this issue: http://code.google.com/p/web2py/issues/detail?id=731
 
 I have tried a lot of the lines that i found there
 
 something like:
 
 if self.db:
 from gluon.dal import BaseAdapter
 BaseAdapter.close_all_instances(None)
 BaseAdapter.close_all_instances('commit')
 BaseAdapter.close_all_instances('rollback')
 
 something like:
 if self.db:
 from gluon.dal import thread as dal_thread
 dal_thread.instances.remove(self.db._adapter)
 self.db._adapter.close()
 
 and even something desesperated like:
 if self.db:
 from gluon.dal import thread as dal_thread
 dal_thread.instances.remove(self.db._adapter)
 self.db._adapter.close()
 self.db._adapter.close_all_instances(None)
 self.db._adapter.close_all_instances('commit')
 self.db._adapter.close_all_instances('rollback')
 
 from gluon.dal import ConnectionPool
 ConnectionPool.close_all_instances(None)
 ConnectionPool.close_all_instances('commit')
 ConnectionPool.close_all_instances('rollback')
 
 from gluon.dal import BaseAdapter
 BaseAdapter.close_all_instances(None)
 BaseAdapter.close_all_instances('commit')
 BaseAdapter.close_all_instances('rollback')
 
 But always, in the best, it leaves at least one connection opened, and i 
 don't know how to deal with it.
 
 I have using web2py 1.99.7 in both development and production environments.
 
 Any ideas? in this moment we are building a python mysql script, but we want 
 to use DAL to make it runnable on any of the web2py/DAL supported db
 
 Thanks in advance