.sendto() method does not work on windows

Asked by Max

Hi,

I developed a sikuli python script on linux that uses this code:

from socket import AF_INET, SOCK_DGRAM
import sys
import socket
import struct, time

host = "pool.ntp.org"
port = 123
buf = 1024
address = (host,port)
msg = '\x1b' + 47 * '\0'

# reference time (in seconds since 1900-01-01 00:00:00)
TIME1970 = 2208988800L # 1970-01-01 00:00:00

# connect to server
client = socket.socket( AF_INET, SOCK_DGRAM)
client.sendto(msg, address)
msg, address = client.recvfrom( buf )

t = struct.unpack( "!12I", msg )[10]
t -= TIME1970

current_time = time.ctime(t).replace(" "," ")

The code is working fine under linux, but if I use sikulix on windows it crashes (at line => client.sendto(msg, address) ) with the following error:

[error] script [ Sikuli_Test_Original ] stopped with error in line 23
[error] _socket.error ( [Errno -1] Unmapped exception: java.util.concurrent.RejectedExecutionException: event executor terminated )
[error] --- Traceback --- error source first line: module ( function ) statement 359: _socket ( handle_exception ) _socket.error: [Errno -1] Unmapped exception: java.util.concurrent.RejectedExecutionException: event executor terminated
995: _socket ( sendto ) File "C:\Users\myuser\Documents\Sikuli\sikulix.jar\Lib\_socket.py", line 971, in _datagram_connect
[error] --- Traceback --- end --------------

Any idea why and how to fix it?

Question information

Language:
English Edit question
Status:
Expired
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

You use non-Sikulix Features. Better ask on stackoverflow.com
Same Jython on both systems?
Use latest SikuliX.

Revision history for this message
Max (max883) said :
#2

The same code on sikulix linux is working fine.
In both OS I have the latest sikulix.

Revision history for this message
Max (max883) said :
#3

I think is a sikuli issue since, if I run a python script with these lines, the code is working properly (on windows).
From the error logs I had the impression that sikuli tried to use its own _socket.py

Revision history for this message
TestMechanic (ndinev) said :
#4

Some thoughts on the topic
Are you running the code from IDE? Try from console
Note that lang spec for jython in Sikuli is older than recent pythons
You can always import other socked.py that is working on Windows

Revision history for this message
Max (max883) said :
#5

Yep, I'm running the code from IDE. In stackoverflow someone suggested to use run() function in sikuli and call an external python script . Any idea how to use it?

Revision history for this message
RaiMan (raimund-hocke) said :
#6

solved?

Revision history for this message
Launchpad Janitor (janitor) said :
#7

This question was expired because it remained in the 'Needs information' state without activity for the last 15 days.