A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://cloud.google.com/appengine/docs/legacy/standard/python/sockets below:

Sockets API for legacy bundled services | App Engine standard environment for Python 2

Sockets API for legacy bundled services

Stay organized with collections Save and categorize content based on your preferences.

Caution: This solution is no longer recommended: Apps that use this API can only run in the Python 2 runtime and will need to upgrade to a recommended solution before migrating to the Python 3 runtime.

Traffic from sockets is billed as

outgoing bandwidth

. Async IO (such as

Twisted

in Python) is not supported. App Engine supports the standard Python socket module API for outbound sockets only. You simply import the standard socket library using the following statement:

import socket

Libraries that import socket, such as poplib or nntplib, and that don't violate the limitations and restrictions listed below, should work without modification.

Although the Python 2 runtime supports sockets, there are certain limitations and behaviors you need to be aware of when using sockets.

You can pickle a socket descriptor and pass it between App Engine instances, such as part of a Task payload. In this scenario, you can open a socket on a frontend instance, and then pass it to a backend instance and use it there.

In SDK versions prior to 1.8.1, you could not call get/set options against sockets. (Doing so raised "Not Implemented" exceptions.) However, the Sockets API now allows this.

For supported options, calls to getsockopt will return a mock value and calls to setsockopt will be silently ignored. Errors will continue to be raised for unsupported options. The supported options are:

Limitations and restrictions

Socket support in App Engine has the following limitations:

Using sockets with the development server

You can run and test code using sockets on the development server, without using any special command line parameters.

Using sockets with OpenSSL

App Engine supports native Python OpenSSL for the Python 2.7 runtime. You must configure your app.yaml file to load the ssl library, as described in OpenSSL Support.

Disabling URL Fetch from handling all outbound requests

If you import httplib, by default it will use the urlfetch api. To change this so that httplib uses sockets instead, add the following environment variable to your app.yaml file:

 env_variables:
   GAE_USE_SOCKETS_HTTPLIB : 'anyvalue'

You can replace anyvalue with any value including an empty string.

App Engine sample using sockets

For a sample using sockets, see the socket demo app in the Google Cloud Platform GitHub.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-08-07 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["This Sockets API is only functional within the Python 2 runtime, and it's recommended to use an alternative solution before migrating to the Python 3 runtime."],["App Engine supports the standard Python socket module API, but only for outbound sockets, and libraries like `poplib` or `nntplib` can work if they adhere to specified limitations."],["Sockets have specific restrictions in App Engine, including the inability to create listen sockets, blocked protocols such as FTP, and the blocking of specific IP ranges."],["Socket descriptors can be passed between App Engine instances, for example, from a frontend to a backend instance."],["By default, `httplib` uses the URL fetch API, but you can configure it to use sockets instead by setting the `GAE_USE_SOCKETS_HTTPLIB` environment variable in your `app.yaml` file."]]],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4