Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit 2f35346

Browse files
mosquitofxdgear
authored andcommitted
rst formatting and python 3.5+ example (#51)
1 parent 9a603a3 commit 2f35346

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

README

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,27 @@ response.
77

88
Sniffing (when requested) is also done via a scheduled coroutine.
99

10-
Example::
10+
Example for python 3.5+
11+
12+
.. code-block:: python
13+
14+
import asyncio
15+
from elasticsearch_async import AsyncElasticsearch
16+
17+
client = AsyncElasticsearch(hosts=['localhost', 'other-host'])
18+
19+
async def print_info():
20+
info = await client.info()
21+
print(info)
22+
23+
loop = asyncio.get_event_loop()
24+
loop.run_until_complete(print_info())
25+
loop.run_until_complete(client.transport.close())
26+
loop.close()
27+
28+
Example for python 3.4
29+
30+
.. code-block:: python
1131

1232
import asyncio
1333
from elasticsearch_async import AsyncElasticsearch
@@ -25,7 +45,9 @@ Example::
2545
loop.close()
2646

2747

28-
Example with SSL Context::
48+
Example with SSL Context
49+
50+
.. code-block:: python
2951

3052
import asyncio
3153
from elasticsearch_async import AsyncElasticsearch
@@ -61,10 +83,13 @@ used to pass in an event loop you wish the client to use. By default
6183
Installation
6284
------------
6385

64-
``elasticsearch-async`` is available via PyPI so you can install it using pip::
86+
``elasticsearch-async`` is available via PyPI so you can install it using pip
87+
88+
.. code-block:: bash
6589

6690
pip install elasticsearch-async
6791

92+
6893
License
6994
-------
7095

0 commit comments

Comments
 (0)