Web2py crash if i define model with function

108 views
Skip to first unread message

Diogo Munaro

unread,
Nov 11, 2013, 4:43:49 AM11/11/13
to web...@googlegroups.com

Hi guys, first the problem:

I need some databases with identical structure, but with different data. These databases must be stored with the clients because they want (different locations), but the auth system is unique.

So, my structure by now is: a centralized auth system and some disyributed databases. The centralized system controls access to other databases.

Teoricaly web2py works great with it, because I defined a function that I pass connection string, access control db and its made a lot of databases replicas with foreign keys to access control database.

Without the function it works great, but with, it make a complete first client database and then crash all of web2py. It returns a ciclic ticket error when I try access any application of that web2py, either Welcome application.

Im using web2py 2.7.4 with mysql on ubuntu. So, whats happening? I cant define model with function. Oh, my function is in the same model file.

BR, Diogo

Michele Comitini

unread,
Nov 11, 2013, 5:34:44 AM11/11/13
to web...@googlegroups.com
If you define a function like
def f():
  pass

in a model, you should have no problems.  
Just show us an extract of code that causes the problem, without violating any reserved information or IP.
That way we can help you...

mic

Diogo Munaro

unread,
Nov 11, 2013, 8:32:49 AM11/11/13
to web...@googlegroups.com
It's not a simple function, but putting the model definition inside the function.

Here the code: http://pastebin.com/rN7gvAT8

Attached the error ticket
127.0.0.1.2013-11-05.23-08-33.49db8c13-8fac-4ac3-bdc1-fdd2fc69abd6

Michele Comitini

unread,
Nov 11, 2013, 6:34:41 PM11/11/13
to web...@googlegroups.com
What happens if you remove the index creation inside the try/except block?


2013/11/11 Diogo Munaro <diogo....@gmail.com>

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Diogo Munaro

unread,
Nov 11, 2013, 7:57:20 PM11/11/13
to web...@googlegroups.com
The error continues, but without index :(

The indexes are successful created


2013/11/11 Michele Comitini <michele....@gmail.com>
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/_OnWZGMqkE0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.

Michele Comitini

unread,
Nov 12, 2013, 4:33:10 AM11/12/13
to web...@googlegroups.com
The error you sent seems to point to some statement that has not been properly closed.  The commit/rollback happens in the middle of an open statement?  That is what mysql seems to say.  The problem could be earlier than when the error raises.

Hard to say where. You could try to force db.commit/rollback in different places to see where you start see errors.



2013/11/12 Diogo Munaro <diogo....@gmail.com>

Diogo Munaro

unread,
Nov 12, 2013, 6:29:10 AM11/12/13
to web...@googlegroups.com

Yes, thanks Michele!

Omg, I was using web2py with apache. With the same code and using rocket server no errors occurs and the databases was created.

I configured apache with web2py script. Someone knows whats happen?

Anyway, now I can configure database with rocket than manage with apache. It's working now!

I think some index makes apache/mysql crazy and returned this error:


1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.

Traceback (most recent call last):
File "/var/www/sistema/gluon/main.py", line 550, in wsgibase
BaseAdapter.close_all_instances('rollback')
File "/var/www/sistema/gluon/dal.py", line 558, in close_all_instances
db._adapter.close(action)
File "/var/www/sistema/gluon/dal.py", line 538, in close
getattr(self, action)()
File "/var/www/sistema/gluon/dal.py", line 1789, in rollback
return self.connection.rollback()
ProgrammingError: (2014, "Commands out of sync; you can't run this command now")

Thanks Michele, if I have some news I'll post here. I'll try using commits at each index creation.

Michele Comitini

unread,
Nov 12, 2013, 7:00:21 AM11/12/13
to web...@googlegroups.com
Seem a threading issue.  
Try : 
 1) pass a pool_size=n option with different values of n
 2) use preforking instead of threading in apache configuration




2013/11/12 Diogo Munaro <diogo....@gmail.com>

Diogo Munaro

unread,
Nov 12, 2013, 2:02:58 PM11/12/13
to web...@googlegroups.com
It's not working...

1- I tried pool_size with n = 2, 3, 6;
2- apache with prefork

I just need to restart apache once a time when de database is created.
It's really strange... but works...


2013/11/12 Michele Comitini <michele....@gmail.com>

Diogo Munaro

unread,
Nov 12, 2013, 3:04:56 PM11/12/13
to web...@googlegroups.com
Hey Michele!

Now it's working... The indexes are crashing web2py on apache.

With a list of indexes I can execute sql in a for:

    for i in indices:
        try:
            db.executesql(i)
        except:pass

Thx for all help!


2013/11/12 Diogo Munaro <diogo....@gmail.com>
Reply all
Reply to author
Forward
0 new messages