search-api Pylucene Kill processus.

36 views
Skip to first unread message

xav4django

unread,
Mar 26, 2007, 8:51:01 AM3/26/07
to django-d...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi.

My probleme with search-api and lucene :

I make index and search with a script python test.py.
python manage.py shell < test.py
It's ok, and give me results.

But when I use this.
python manage.py runserver 8080 --verbosity=2

and add the first line in a view script :
from django.contrib.search.backends import LuceneIndexer

When I call a page, the processus runserver crash !!!
No error message in console !


Peharps an install error ?

I use debian etch
I user svn django version.
Database postgres8.1.

I think my PyLucene install is ok (make test is ok).
Detail : http://www.1et0.org/admin/db/pylucene (with some french sorry).

I am not sure my install method search-api is correct.
I just copy the svn checkout
django/branches/search-api/django/contrib/search
in
/usr/lib/python2.4/site-packages/django/contrib/

Idea and advise wellcome.


Thx.
Xavier. Noobs in django (first django application).

x...@1et0.org

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGB8G14dg3EDuiPUcRAiaZAJ9hUvECeuuUfsEvJPGVoKhdzP9KUQCeMBnG
Zq4n4ZfoWaQ1uMZI5Hxwm7M=
=1IJg
-----END PGP SIGNATURE-----

test.py

Norjee

unread,
Mar 26, 2007, 9:03:53 AM3/26/07
to Django developers
Pylucene has some threading issues (read incompatibilities with python
threads, it must be run from either the main thread, or its own thread
version).

The solution is rather simple, use it in its own separte thread. See
for example turbolucene, http://dev.krys.ca/turbolucene/

xav4django

unread,
Mar 26, 2007, 9:13:42 AM3/26/07
to django-d...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Thx :)

Norjee a écrit :

-----BEGIN PGP SIGNATURE-----


Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGB8cG4dg3EDuiPUcRArWLAJ4yEo4dbN5Nup9GsQRrvSp5IGnuFACfU/I2
B/fBhs8VyR0l/LjI7mSMz9s=
=uX5t
-----END PGP SIGNATURE-----

xav4django

unread,
Mar 26, 2007, 9:41:13 AM3/26/07
to django-d...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Solution found in pylucene-dev :

changed django/utils/autoreload.py
from:
import thread
to:
import PyLucene.PythonThread as thread

Norjee a écrit :

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGB8154dg3EDuiPUcRAjSEAJ9UCCcNK98gwCSsKA5cyTjUIs4axwCfa6Pa
fzPgFykklqUxV8iridyKOqA=
=3eai
-----END PGP SIGNATURE-----

Norjee

unread,
Mar 26, 2007, 3:21:53 PM3/26/07
to Django developers
I'm afraid your solution only works when using the development server,
and even then when used in auto_reload mode.
I think the easiest solution is to simply execute the functions
interfacing with pylucene in their own thread. something like:
def search(query):
- delegate work to new pylucene thread
- join it with current thread
- do something with result

I guess you could even create a decorator for such functions
interfacing with pylucene..


On 26 mrt, 15:41, xav4django <xav4dja...@yahoo.fr> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Solution found in pylucene-dev :
>
> changed django/utils/autoreload.py
> from:
> import thread
> to:
> import PyLucene.PythonThread as thread
>
> Norjee a écrit :
>
> > Pylucene has some threading issues (read incompatibilities with python
> > threads, it must be run from either the main thread, or its own thread
> > version).
>
> > The solution is rather simple, use it in its own separte thread. See

> > for example turbolucene,http://dev.krys.ca/turbolucene/


>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)

> Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org

xav4django

unread,
Apr 3, 2007, 5:40:16 AM4/3/07
to django-d...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Norjee a écrit :


> I'm afraid your solution only works when using the development server,
> and even then when used in auto_reload mode.

You are in true.

> I think the easiest solution is to simply execute the functions
> interfacing with pylucene in their own thread. something like:
> def search(query):
> - delegate work to new pylucene thread
> - join it with current thread
> - do something with result
>
> I guess you could even create a decorator for such functions
> interfacing with pylucene..

It's didn't work for me. Do you have a succes with this ?

I do some test for pylucene.
My results :
pylucene + django without mod-python : succes here.
http://www.1et0.org/admin/db/pylucene/django-without-mod-python

I test PyLucene.PythonThread.
It's work with thread and django shell, but crash with mod_python.

I test JvAttachCurrentThread
(I make a patch for pylucene for add the wrapper)
http://www.1et0.org/admin/db/pylucene/trypatch/patch.txt
It's work with thread and django shell, but crash with mod_python.

More info about my test here
http://www.1et0.org/admin/db/pylucene/trypatch

my sample test thread are here :
testthread.py : thread simple (error with shell, error with mod_python)
testthread2.py : thread solution. (ok with shell error with mod_python)
testthread3.py : patch JvAttachCurrentThread2 (ok with shell, error with
mod_python)

My question is :
Anyone have a succes for pylucene, django and mod_python ?
Someone did test pylucene with mod_fastcgi ?

Thx, Xavier.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGEiEA4dg3EDuiPUcRAuy2AJ9WOU+08NYSdyLVOPsxXDkBxm34bgCeKs3o
M9g+RUty6mk1fEXGNwArC8o=
=VWja
-----END PGP SIGNATURE-----

Ian Holsman

unread,
Apr 3, 2007, 5:45:13 AM4/3/07
to django-d...@googlegroups.com
Hi.

this isn't exactly an answer for your question (using lucene with mod-
python).
put you might want to look at Solr ( http://lucene.apache.org/solr/ )
which wraps the lucene search engine in a HTTP server.

the benefits are:
- scalability
- no mucking about with language wrappers like pylucene and threading
issues you are currently having
- easier to access the search collection from other applications.

regards
Ian

--
Ian Holsman
I...@Holsman.net
http://peopleintopoker.com/ -- where the poker people go


xav4django

unread,
Apr 3, 2007, 8:06:29 AM4/3/07
to django-d...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ian Holsman a écrit :


> put you might want to look at Solr ( http://lucene.apache.org/solr/ )
> which wraps the lucene search engine in a HTTP server.

Thx. I will see that.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGEkNE4dg3EDuiPUcRAoXjAJ4u4jf023NVheQ1gwAf7+kNJL2SPQCfQD7G
V9o9nUKUtd2Pj9aWVAB3RRU=
=mR9C
-----END PGP SIGNATURE-----

Reply all
Reply to author
Forward
0 new messages