Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

51 linhas
1.5KB

  1. from eventlet import patcher
  2. from eventlet.green import ftplib, http, os, socket, time
  3. from eventlet.green.http import client as http_client
  4. from eventlet.green.urllib import error, parse, response
  5. # TODO should we also have green email version?
  6. # import email
  7. to_patch = [
  8. # This (http module) is needed here, otherwise test__greenness hangs
  9. # forever on Python 3 because parts of non-green http (including
  10. # http.client) leak into our patched urllib.request. There may be a nicer
  11. # way to handle this (I didn't dig too deep) but this does the job. Jakub
  12. ('http', http),
  13. ('http.client', http_client),
  14. ('os', os),
  15. ('socket', socket),
  16. ('time', time),
  17. ('urllib.error', error),
  18. ('urllib.parse', parse),
  19. ('urllib.response', response),
  20. ]
  21. try:
  22. from eventlet.green import ssl
  23. except ImportError:
  24. pass
  25. else:
  26. to_patch.append(('ssl', ssl))
  27. patcher.inject('urllib.request', globals(), *to_patch)
  28. del to_patch
  29. to_patch_in_functions = [('ftplib', ftplib)]
  30. del ftplib
  31. FTPHandler.ftp_open = patcher.patch_function(FTPHandler.ftp_open, *to_patch_in_functions)
  32. URLopener.open_ftp = patcher.patch_function(URLopener.open_ftp, *to_patch_in_functions)
  33. ftperrors = patcher.patch_function(ftperrors, *to_patch_in_functions)
  34. ftpwrapper.init = patcher.patch_function(ftpwrapper.init, *to_patch_in_functions)
  35. ftpwrapper.retrfile = patcher.patch_function(ftpwrapper.retrfile, *to_patch_in_functions)
  36. del error
  37. del parse
  38. del response
  39. del to_patch_in_functions