PyTango9.2.1 on win32. Server crashes when calling PyTango.Server.run

Hi (Py)Tango experts,
I have a problem with PyTango9.2.1. The server does not start (crashes)
The Platform is Windows7 32 (WIN32). Python27. Visual Studio 2008 (vc9).
I use Tango9.2.2 (compiled for win32(vc9) downloaded from this site) which I link dynamically.
I used first PyTango9.2.0 (Compiled by Sebastien @ Nexeya). and I had the problem.
Then I compiled PyTango9.2.1 (Sources from this site).
Compiled with VC9 (visual studio 2008), Win32
Boost_python 1.63.0 (I compiled boost with debug symbols (to see the debugger) for win32 as well, dynamically linked, with dynamic runtime)


This is the problem. When I call:
PyTango.Server.run

It crashes (with this message):
 
Unhandled exception at 0x10302d64 (_tango.pyd) in python.exe: 0xC0000005: Access violation writing location 0x103255a0.
The Tango database it is connecting to is the local host (Tango8.1.2b Win32 installation). It happens the same with a tango7 database. I haven't tested connecting to a Tango9 database…
This is my example code, but it happens with all servers : (file: MyServer.py):

from PyTango.server import run, Device, command
class DfcPyTest(Device):
    @command(din_type=str, dout_type=str)
    def hello(self, message):
        return message + ' Hi, how are you'
if __name__ == "__main__":
    run([DfcPyTest])
And this the output of the debugger, just in case… (sorry for the long-scroll and many thanks in advance…). Any idea or clue would be very appreciated (my other question is: does anybody use this configuration (Win32, python27, vc9, Pytango9.2.X)?. Thank you so much.


 	_tango.pyd!PyUtil::server_init()  + 0x34 bytes	C++
 	_tango.pyd!server_init_overload::non_void_return_type::gen<boost::mpl::vector3<void,Tango::Util &,bool> >::func_0()  + 0xc bytes	C++
 	_tango.pyd!boost::python::objects::caller_py_function_impl<boost::python::detail::caller<void (*)(Tango::Util &),boost::python::default_call_policies,boost::mpl::vector2<void,Tango::Util &> > >::operator()()  + 0x3b bytes	C++
>	boost_python-vc90-mt-gd-1_63.dll!boost::python::objects::py_function::operator()(_object * args=0x01737c70, _object * kw=0x00000000)  Line 148	C++
 	boost_python-vc90-mt-gd-1_63.dll!boost::python::objects::function::call(_object * args=0x01737c70, _object * keywords=0x00000000)  Line 226 + 0x24 bytes	C++
 	boost_python-vc90-mt-gd-1_63.dll!boost::python::objects::`anonymous namespace'::bind_return::operator()()  Line 585 + 0x19 bytes	C++
 	boost_python-vc90-mt-gd-1_63.dll!boost::detail::function::void_function_ref_invoker0<boost::python::objects::`anonymous namespace'::bind_return,void>::invoke(boost::detail::function::function_buffer & function_obj_ptr={…})  Line 195	C++
 	boost_python-vc90-mt-gd-1_63.dll!boost::function0<void>::operator()()  Line 771 + 0x14 bytes	C++
 	boost_python-vc90-mt-gd-1_63.dll!boost::python::detail::exception_handler::operator()(const boost::function0<void> & f={…})  Line 75	C++
 	_tango.pyd!boost::python::detail::translate_exception<Tango::NotAllowed,void (*)(Tango::NotAllowed const &)>::operator()()  + 0x35 bytes	C++
 	_tango.pyd!boost::detail::function::function_obj_invoker2<boost::_bi::bind_t<bool,boost::python::detail::translate_exception<Tango::NotAllowed,void (*)(Tango::NotAllowed const &)>,boost::_bi::list3<boost::arg<1>,boost::arg<2>,boost::_bi::value<void (*)(Tango::NotAllowed const &)> > >,bool,boost::python::detail::exception_handler const &,boost::function0<void> const &>::invoke()  + 0x17 bytes	C++
 	boost_python-vc90-mt-gd-1_63.dll!boost::function2<bool,boost::python::detail::exception_handler const &,boost::function0<void> const &>::operator()(const boost::python::detail::exception_handler & a0={…}, const boost::function0<void> & a1={…})  Line 771 + 0x1c bytes	C++
 	boost_python-vc90-mt-gd-1_63.dll!boost::python::detail::exception_handler::handle(const boost::function0<void> & f={…})  Line 42	C++
 	boost_python-vc90-mt-gd-1_63.dll!boost::python::detail::exception_handler::operator()(const boost::function0<void> & f={…})  Line 70 + 0xf bytes	C++
 	_tango.pyd!boost::python::detail::translate_exception<Tango::DeviceUnlocked,void (*)(Tango::DeviceUnlocked const &)>::operator()()  + 0x35 bytes	C++
 	_tango.pyd!boost::detail::function::function_obj_invoker2<boost::_bi::bind_t<bool,boost::python::detail::translate_exception<Tango::DeviceUnlocked,void (*)(Tango::DeviceUnlocked const &)>,boost::_bi::list3<boost::arg<1>,boost::arg<2>,boost::_bi::value<void (*)(Tango::DeviceUnlocked const &)> > >,bool,boost::python::detail::exception_handler const &,boost::function0<void> const &>::invoke()  + 0x17 bytes	C++
 	boost_python-vc90-mt-gd-1_63.dll!boost::function2<bool,boost::python::detail::exception_handler const &,boost::function0<void> const &>::operator()(const boost::python::detail::exception_handler & a0={…}, const boost::function0<void> & a1={…})  Line 771 + 0x1c bytes	C++
 	boost_python-vc90-mt-gd-1_63.dll!boost::python::detail::exception_handler::handle(const boost::function0<void> & f={…})  Line 42	C++
 	boost_python-vc90-mt-gd-1_63.dll!boost::python::detail::exception_handler::operator()(const boost::function0<void> & f={…})  Line 70 + 0xf bytes	C++
 	_tango.pyd!boost::python::detail::translate_exception<Tango::EventSystemFailed,void (*)(Tango::EventSystemFailed const &)>::operator()()  + 0x35 bytes	C++
 	_tango.pyd!boost::detail::function::function_obj_invoker2<boost::_bi::bind_t<bool,boost::python::detail::translate_exception<Tango::EventSystemFailed,void (*)(Tango::EventSystemFailed const &)>,boost::_bi::list3<boost::arg<1>,boost::arg<2>,boost::_bi::value<void (*)(Tango::EventSystemFailed const &)> > >,bool,boost::python::detail::exception_handler const &,boost::function0<void> const &>::invoke()  + 0x17 bytes	C++
 	boost_python-vc90-mt-gd-1_63.dll!boost::function2<bool,boost::python::detail::exception_handler const &,boost::function0<void> const &>::operator()(const boost::python::detail::exception_handler & a0={…}, const boost::function0<void> & a1={…})  Line 771 + 0x1c bytes	C++
 	boost_python-vc90-mt-gd-1_63.dll!boost::python::detail::exception_handler::handle(const boost::function0<void> & f={…})  Line 42	C++
 	boost_python-vc90-mt-gd-1_63.dll!boost::python::detail::exception_handler::operator()(const boost::function0<void> & f={…})  Line 70 + 0xf bytes	C++
 	_tango.pyd!boost::python::detail::translate_exception<Tango::AsynReplyNotArrived,void (*)(Tango::AsynReplyNotArrived const &)>::operator()()  + 0x35 bytes	C++
 	_tango.pyd!boost::detail::function::function_obj_invoker2<boost::_bi::bind_t<bool,boost::python::detail::translate_exception<Tango::AsynReplyNotArrived,void (*)(Tango::AsynReplyNotArrived const &)>,boost::_bi::list3<boost::arg<1>,boost::arg<2>,boost::_bi::value<void (*)(Tango::AsynReplyNotArrived const &)> > >,bool,boost::python::detail::exception_handler const &,boost::function0<void> const &>::invoke()  + 0x17 bytes	C++
 	boost_python-vc90-mt-gd-1_63.dll!boost::function2<bool,boost::python::detail::exception_handler const &,boost::function0<void> const &>::operator()(const boost::python::detail::exception_handler & a0={…}, const boost::function0<void> & a1={…})  Line 771 + 0x1c bytes	C++
 	boost_python-vc90-mt-gd-1_63.dll!boost::python::detail::exception_handler::handle(const boost::function0<void> & f={…})  Line 42	C++
 	boost_python-vc90-mt-gd-1_63.dll!boost::python::detail::exception_handler::operator()(const boost::function0<void> & f={…})  Line 70 + 0xf bytes	C++
 	
(…)


 	python27.dll!53f33d9b() 	
 	python.exe!1c931180() 	
 	kernel32.dll!75f4ef1c() 	
 	ntdll.dll!7777367a() 	
 	ntdll.dll!7777364d() 	

Edited 7 years ago
Hi David,

I am not a PyTango on Win32 expert but I did notice that the code you gave does not work on Linux. If I modify it to this (notice dtype_in instead of din_type …):

from PyTango.server import run, Device, DeviceMeta, command
import six
@six.add_metaclass(DeviceMeta)
class DfcPyTest(Device):
    @command(dtype_in=str, dtype_out=str)
    def hello(self, message):
        return message + ' Hi, how are you'
if __name__ == "__main__":
    run([DfcPyTest])
I don't know if you need to import six and specify DeviceMeta. I let the PyTango gurus correct my code.

Then I can run it from itango as follows:
In [9]: dev=DfcPyTest("test/dfcpytest/1")
In [10]: dev.hello("David")
Out[10]: 'David Hi, how are you'

Do you need Win32 support for the future? If so we need to include it in the Tango support contract we are preparing.

Cheers

Andy
Edited 7 years ago
Oups!!.
My mistake. Many thanks for the quick answer.
It does not work either, i am affraid… The reason behind this post is that I Created the simple server for tests purposes after trying to run LimaCCDs.py (which was crashing and did not work in my system).
BTW… do you need to import six?… I though it is used by PyTango so you do not need to explicitly import it…
Actually this particular configuration is very unusual. We have very few servers running on Windows and even less running on win32 (PyTango7). This particular case pretended to be a quick test for a prototype camera that we have (XCAM) running Lima+Tango… As most quick tests it ends up being "a bit" longer. The reason for this test is that XCAM provides a dll communicating with the camera by an USB interface today only available for win32 (compiled with visual studio 2008 as Lima is). So this test is only a proof of concept. The system in the longer run should run on Linux (debian). So I am not so sure that we should include win32 (very few left nowadays).
Many thanks again.
d.
About the code, I'd write it this way (assuming pytango-9.2.1):

from tango.server import Device, command

class TestDevice(Device):

    @command(dtype_in=str, dtype_out=str)
    def hello(self, message):
        return message + ' Hi, how are you'

if __name__ == "__main__":
    TestDevice.run_server()

So yes, using DeviceMeta is not necessary any more.

Also, note that you can easily run a test device locally using the new test_context module:

$ python -m tango.test_context some_file_name.TestDevice
Can't create notifd event supplier. Notifd event not available
Ready to accept request
TestDevice started on port 8888 with properties {}
Device access: tango://w-vinmic-pc-0:8888/test/nodb/testdevice#dbase=no
Server access: tango://w-vinmic-pc-0:8888/dserver/TestDevice/testdevice#dbase=no

You can then access the device with a regular proxy:

$ itango
In [1]: d = Device('tango://w-vinmic-pc-0:8888/test/nodb/testdevice#dbase=no')
In [2]: d.hello('David')
Out[2]: 'David Hi, how are you'

Now about the windows build, I have no idea what the problem is, but I know it's very tricky to build pytango for windows. To my knowledge, only Tiago Coutinho and Sébastien Gara have a working setup for building pytango.

Cheers
Hi David,

Sorry for making you compile PyTango on windows. It is a inhuman task smile. Let's try to make it better.

There seems to be a project to do a proper automated build for windows which could avoid this problems it the future. I don't know the state of this project so let's focus in solving your problem:

First, and for the immediate situation, let me say that I usually build PyTango windows on a request basis so if you need I can do it for the latest tango/pytango. Sometimes, depending on the python version and the platform, I need to ask specifically to the tango c++ team for a static tango library.

I used first PyTango9.2.0 (Compiled by Sebastien @ Nexeya). and I had the problem.
I don't know how Sebastien compiled PyTango so I have little clue.
Is there a way to get this installer somehow?

I use Tango9.2.2 (compiled for win32(vc9) downloaded from this site) which I link dynamically.
This is already a good hint. PyTango must be compiled using the Tango static library and the boost static library. It will probably not work if you link with the shared libraries. This is because of potential conflicts (DLL hell) between the version of MSVCRT.DLL which was used to compile python and the version which was used to compile tango.

The instructions to build PyTango on windows are in doc/windows_notes.txt.
I just had a quick look at them and they are missing the tango chapter so sorry for that. I will try to finish it.

Before I continue, I need to know if you would prefer that I make a distribution of PyTango or if you want to continue debugging until you have a working compilation.

In the mean time, if it unblocks you, you can find the latest windows binaries for PyTango 8.1.6 in PyPI. This is the version we use at ESRF for Lima windows servers so it should be fine.



Cheers
Edited 7 years ago
I though it is used by PyTango so you do not need to explicitly import it…

six is just a python module that allows you to write python code that is both python 2 and python 3 compatible.
You could avoid using six:

from PyTango.server import run, Device, DeviceMeta, command
class DfcPyTest(Device):
    __metaclass__ = DeviceMeta

but then when your code would not work in python 3.

Anyway, thanks to Vincent the DeviceMeta is not needed since PyTango 9.2.1. We should throw him a party just for this smile
TCoutinho
I don't know how Sebastien compiled PyTango so I have little clue.
Is there a way to get this installer somehow?

Yes, I actually uploaded those installers on PyPI.

Cheers
Hi, Tiago, Vincent, Andy
Many thanks for your help. Actually I tried the PyTango8.1.6 as suggested by Tiago and it works!!!. I tried both 32 and 64 bits on Win7 and Python27 and they both work!!. This is enough for me now.
Thank you so much once again!.
ciao
David
Hi guys,

I have build a pytango 9.2.1 with the latests sources, but only for py27 (32 and 64) for the moment.
I can't build the py34 version now. I have some errors on device_impl.cpp, I will notify them on github.
I will give them to Vincent for uploading them on pypi. But they will be "untested", just compiled from the sources (don't have a lot of time theses days)

The continuous integration is planned for sure, and I think, will start this year.

The new version is available here :

https://pypi.python.org/pypi/PyTango/9.2.1

Edited 7 years ago
 
Register or login to create to post a reply.