.sendto() method does not work on windows

Asked by Max on 2017-11-12


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

English Edit question
Sikuli Edit question
No assignee Edit question
Last query:
Last reply:
RaiMan (raimund-hocke) said : #1

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

Max (max883) said : #2

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

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

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

Can you help with this problem?

Provide an answer of your own, or ask Max for more information if necessary.

To post a message you must log in.