Commit Graph

25 Commits

Author SHA1 Message Date
Fabio Erculiani 9eb56dbc14 [entropy.const] drop several etpConst constants, replace with more OO vars
etpConst['clientdbid'] is kept for backward compatibility, but will be removed soon
While etpConst['serverdbid'] and etpConst['clientserverrepoid'] are gone.
2013-02-20 00:56:52 +00:00
Fabio Erculiani 4da0c49b07 [entropy.db.sql] move methods used by _addPackage() into class 2012-08-22 17:41:01 +02:00
Fabio Erculiani a37d7ca195 [entropy.db.sqlite] move _addPackage() to entropy.db.sql 2012-08-16 21:35:45 +02:00
Fabio Erculiani 5a49098515 [entropy.db] move _getLiveCacheKey and __hash__ to entropy.db.sql 2012-08-16 21:30:51 +02:00
Fabio Erculiani a0394ba9a5 [entropy.db.sql] introduce _UPDATE_OR_REPLACE and move remaining SQL to entropy.db.sql 2012-08-16 21:20:46 +02:00
Fabio Erculiani 1b10177640 [entropy.db.sql] major cursor and connection pooling rework
The original idea was to avoid doing cursor and connection resources
cleanup (left by old and dead threads) synchronously every time
_connection() and/or _cursor() is accessed. This strategy also had
a huge drawback: with no activity on the object, resources were
left hanging there forever.

This commit introduces a better strategy for transparent and automatic
cleanup of resources belonging to terminated threads: every time a new
thread_id arrives at _cursor() or _connection(), a new daemon thread
starts and synchronizes with the caller through a simple Thread.join()
(because it's a daemon thread, we can join() daemon threads as well,
even if this is not really compliant with the specs, but it seems to work
just fine in Python).
When the caller thread is joined, it is possible to start the resources
cleanup procedure, carefully taking into account that thread_ids are
recycled and thus there might be clashing with newly created threads.

This helped a design issue to emerge from the sand (like a zombie
at the seaside): it is impossible to cleanup resources left by the
MainThread because this thread never ends living, and if it dies,
everything dies, obviously. So, the first implementation of this new
strategy was NOT touching the MainThread resources but then, the old
behaviour was to kill them as well on EntropyRepository.close().
So, the final version of this patch kept the old buggy behaviour of
touching MainThread stuff (nein, nein, nein, nein would Hitler say).
However, a new keyword argument "safe" has been added to the close()
method so it is possible to start migrating code to the dark side of the
power.

This means nothing really changed for API consumers yet, just entropy.db.sql
code being more efficient (no weird for loops and synchronous crap)
and actually faster (multi-threading ftw).
2012-08-15 20:59:45 +02:00
Fabio Erculiani e05b649f98 [entropy.db] remove do_cleanup argument from removePackage() 2012-08-12 16:15:23 +02:00
Fabio Erculiani 9d665e050c [entropy.db] remove do_commit argument from methods 2012-08-12 16:00:02 +02:00
Fabio Erculiani f9ee58b48f [entropy.db.sql] add SQLConnectionWrapper.rawstring() and docstrings 2012-08-12 12:51:58 +02:00
Fabio Erculiani c5e80d4153 [entropy.db.sql] define a common API for Cursor and Connection wrappers 2012-08-12 11:39:36 +02:00
Fabio Erculiani beb21f1660 [entropy.db] move other standard SQL code to entropy.db.sql 2012-08-12 10:29:41 +02:00
Fabio Erculiani 27a51598a0 [entropy.db] move most of the standard SQL code to entropy.db.sql 2012-08-11 21:58:41 +02:00
Fabio Erculiani 7a950cb4b9 [entropy.db] abstract exceptions away from sqlite3
Wrap the Cursor object around and execute every method through
a proxy function that catches adapter-specific exceptions and
translates them into entropy.db.exceptions ones. This way Entropy
is eventually sqlite3 agnostic and adapters for several storage
engines can be written without affecting the rest of the codebase.
2012-08-10 21:35:50 +02:00
Fabio Erculiani 2e6e790677 [entropy.db.sqlite] EntropyRepository.retrieveSignatures: check if table exists 2012-08-10 14:06:24 +02:00
Fabio Erculiani 0461ca413a [entropy.db] do not check if "settings" table exists, we're fault tolerant 2012-08-10 14:05:31 +02:00
Fabio Erculiani dc4556ef46 [entropy.db] create entropy.db.sql (holding standard SQL methods)
entropy.db.mysql and entropy.db.sqlite are now subclassing
EntropySQLRepository. Methods will be moved there during the
next forthcoming overhaul. Implement ModuleProxy support and
alleviate the exception class objects issue (sqlite3 based
exceptions are thrown by entropy.db.sqlite and oursql based
exceptions are thrown by entropydb.mysql, and there is no
easy/quick fix for this apparently, besides wrapping all the
cursor calls).
2012-08-10 11:41:29 +02:00
Fabio Erculiani 8ebf92f17b [entropy.db.sqlite] enable _SCHEMA_2010_SUPPORT by default. 2012-08-10 10:24:57 +02:00
Fabio Erculiani 2bac80d76a [entropy.db.sqlite] catch OperationalError instead of Error 2012-08-09 17:25:11 +02:00
Fabio Erculiani 37e1d0f465 [entropy.db.sqlite] always enforce LIMIT 1 when using Cursor.fetchone()
Certain adapters don't clear cursor data automatically if fetchone()
is used and LIMIT 1 is not enforced.
2012-08-09 15:05:06 +02:00
Fabio Erculiani ea17f96d99 [entropy.db.sqlite] check if settings table exists before spawning schema updates 2012-08-09 15:04:16 +02:00
Fabio Erculiani 690984caf4 [entropy.db.sqlite] fix query statement 2012-08-09 13:40:24 +02:00
Fabio Erculiani 7e6c9530c1 [entropy.db] move alignDatabases() to entropy.db.skel class 2012-08-09 13:40:04 +02:00
Fabio Erculiani ad74ade00c [entropy.db] add MySQL connector (barely tested !!!) 2012-08-08 18:47:25 +02:00
Fabio Erculiani a1e7d92bfb [entropy.db.sqlite] trivial fixes (remove imports, catch IOError, etc) 2012-08-08 17:10:20 +02:00
Fabio Erculiani a7f958afd1 [entropy.db] split entropy.db package module into cache and sqlite 2012-08-08 11:11:42 +02:00