More robust Python/Ruby version detection

Version detection code now checks only the port related messages in case
if it runs from another process with its own messages in the queue