3

I am testing out an app in GAE. It runs fine when deployed to Google's server, but locally it crashes because it cannot import name RAND_egd. The place where it happens is in C:\Program Files(x86)Google\google_appengine\google\appengine\dist27\socket.py line 73:

from _ssl import RAND_add, RAND_egd, RAND_status, SSL_ERROR_ZERO_RETURN, SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE, SSL_ERROR_WANT_X509_LOOKUP, SSL_ERROR_SYSCALL, SSL_ERROR_SSL, SSL_ERROR_WANT_CONNECT, SSL_ERROR_EOF, SSL_ERROR_INVALID_ERROR_CODE

According to this SO answer, the solution is to comment out the import, but that was in the standard socket.py. I removed RAND_egd from the Google supplied file, and it worked, for now.

What is the proper solution to this problem? Will RAND_egd always be not needed in socket.py? Is that Google supplied socket.py not the same as the one in Google's web servers?

Community
  • 1
  • 1
Old Geezer
  • 14,854
  • 31
  • 111
  • 198

1 Answers1

2

There is nothing wrong with your solution. This is due to a bug in socket.py distributed with the SDK 1.9.38.

Windows doesn't support the RAND_egd library.

There is a more elegant workaround that conditionally imports the library if not Windows.

You have to make changes to the file: C:\Program Files (x86)\Google\google_appengine\google\appengine\dist27\socket.py

Then you can use Python later than 2.7.9 with the Windows App Engine SDK,

The required changes to the file are described here https://code.google.com/p/googleappengine/issues/detail?id=12783

You will need admin access to modify the file. It might be easier to edit the file in a writable location then copy it to the read-only destination.

Check the status of this issue. Hopefully, a new release of the SDK will mean the patch is no longer required. Otherwise, repeat this procedure after each upgrade of the App Engine SDK.

intotecho
  • 4,925
  • 3
  • 39
  • 54
  • I'm installing App Engine onto a new computer, and it seems it must be installed via Google Cloud SDK now (maybe I'm mistaken?) In any case, the location of the socket.py is: `C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\dist27\socket.py` – Nate Anderson Nov 18 '16 at 18:46
  • Moreover, there are two changes from the above Google group. The first is to actually *add* the conditional import described in [the other SO post](http://stackoverflow.com/a/31763219/1175496) – Nate Anderson Nov 18 '16 at 19:04