Re: [Tracker] Tracker closing the databse
- From: Philip Van Hoof <philip codeminded be>
- To: Martyn Russell <martyn lanedo com>, "Putinei .Ionut" <putineiionut gmail com>
- Cc: tracker-list gnome org
- Subject: Re: [Tracker] Tracker closing the databse
- Date: Fri, 05 Jul 2013 00:25:26 +0200
My opinion on this is that objects like cursor and connection should be
marked with an interface called Disposable that defines a method called
Close.
This way developers using it can more easily structure their code.
For example in a language like C# there is a language-specific feature
named "using" for the purpose of supporting classes that implement
Disposable:
public class Connection : IDisposable
{
public void Connect () {
db = sqlite3_open (...);
}
public void Dispose () {
if (db)
sqlite_close (db);
}
}
Client code:
using (Connection conn = new Connection()) {
conn.Connect();
Query = conn.Query("select ...");
foreach (var row in Query.Execute()) {
}
}
This in C# will ensure Connection conn to be disposed by its Dispose
member defined by IDisposable. Implying that sqlite_close is called, for
sure (guaranteed by the C# language).
Whenever a IDisposable isn't used with using and/or its Dispose method
manually called (for example in a finally block of a try-catch-finally),
the compiler by defaults errors or otherwise warns: the developer knows.
For a Vala language binding, this should happen with
Tracker.SparqlConnection. In other language bindings it could also be
handled. And with GObject introspection, code analyzers on GObject C
code could also make those warnings take place at compile time.
What I'm trying to say is that it's not that because we are stupid
enough to do C, that we should ignore or be blind for what is possible
in other typed languages (I'm not a big fan of untyped languages, but
I'll even go as far as to claim that we should even consider listening
to the crazy dynamic language guys - however insanely crazy their
'ideas' are).
Kind regards,
Philip
Martyn Russell schreef op 4/07/2013 22:02:
On 07/03/2013 02:43 PM, Putinei .Ionut wrote:
Hello,
Hello,
I run a bunch for queries with tracker_sparql_connection_query(sync
version).....with same TrackerSparqlConnection.
After 40-50 queries my app hangs.
I see in tracker log that about the same time tracker is closing the
sqlite database.
Do you have any advice for this issue?Could the fact that tracker is
closing database i get the hang?
Are you able to share the code with us?
I suspect you have references open to one or more TrackerSparqlCursor
objects, though it's hard to tell without looking at the code.
Why is the reason to close the database.....since i have seen in code
that close is done in "tracker_db_interface_sqlite_finalize" that is
seem like a destructor function GObject TrackerDBInterface.
Usually, if you unref and finish with the connection we clean up yes.
If you're not expecting this it could be related. Again, sharing the
code would go a long way to help us help you figure out what might be
the problem.
Thanks,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]