mirror of https://github.com/nocturn9x/giambio.git
Small fixes
This commit is contained in:
parent
8e77c40cc1
commit
acdf56c87f
12
README.md
12
README.md
|
@ -12,6 +12,7 @@ production ready, so be aware that it is likely that you'll find bugs and race c
|
||||||
|
|
||||||
Right now this is nothing more than a toy implementation to help me understand how this whole `async`/`await` thing works
|
Right now this is nothing more than a toy implementation to help me understand how this whole `async`/`await` thing works
|
||||||
and it is pretty much guaranteed to explode spectacularly badly while using it. If you find any bugs, please report them!
|
and it is pretty much guaranteed to explode spectacularly badly while using it. If you find any bugs, please report them!
|
||||||
|
|
||||||
Oh and by the way, this project was hugely inspired by the [curio](https://github.com/dabeaz/curio) and the
|
Oh and by the way, this project was hugely inspired by the [curio](https://github.com/dabeaz/curio) and the
|
||||||
[trio](https://github.com/python-trio/trio) projects, you might want to have a look at their amazing work if you need a
|
[trio](https://github.com/python-trio/trio) projects, you might want to have a look at their amazing work if you need a
|
||||||
rock-solid and structured concurrency framework (I personally recommend trio and that's definitely not related to the fact
|
rock-solid and structured concurrency framework (I personally recommend trio and that's definitely not related to the fact
|
||||||
|
@ -27,7 +28,7 @@ actually might be a good choice when it comes to I/O for reasons that span far b
|
||||||
If you choose to use threads, there are a couple things you can do, involving what is known as _thread synchronization
|
If you choose to use threads, there are a couple things you can do, involving what is known as _thread synchronization
|
||||||
primitives_ and _thread pools_, but once again that is beyond the purposes of this quickstart guide.
|
primitives_ and _thread pools_, but once again that is beyond the purposes of this quickstart guide.
|
||||||
A library like giambio comes into play when you need to perform lots of [blocking operations](https://en.wikipedia.org/wiki/Blocking_(computing))
|
A library like giambio comes into play when you need to perform lots of [blocking operations](https://en.wikipedia.org/wiki/Blocking_(computing))
|
||||||
and network servers, among other things, happens to rely heavily on I/O which is a blocking operation.
|
and network servers, among other things, happen to be heavily based on I/O: a blocking operation.
|
||||||
Starting to see where we're heading?
|
Starting to see where we're heading?
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,6 +51,7 @@ def sync_fun(): # A regular (sync) function
|
||||||
First of all, async functions like to stick together: to call an async function you need to put `await` in front of it, like below:
|
First of all, async functions like to stick together: to call an async function you need to put `await` in front of it, like below:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|
||||||
async def async_two():
|
async def async_two():
|
||||||
print("Hello from async_two!")
|
print("Hello from async_two!")
|
||||||
|
|
||||||
|
@ -69,8 +71,10 @@ regular functions: after all, their ability to call other async functions seems
|
||||||
Take a look at this example below:
|
Take a look at this example below:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|
||||||
import giambio
|
import giambio
|
||||||
|
|
||||||
|
|
||||||
async def foo():
|
async def foo():
|
||||||
print("Hello, world!")
|
print("Hello, world!")
|
||||||
|
|
||||||
|
@ -81,9 +85,11 @@ giambio.run(foo) # Prints 'Hello, world!'
|
||||||
This could as well be written the following way and would produce the same output:
|
This could as well be written the following way and would produce the same output:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|
||||||
def foo():
|
def foo():
|
||||||
print("Hello, world!")
|
print("Hello, world!")
|
||||||
|
|
||||||
|
|
||||||
foo() # Prints 'Hello, world!'
|
foo() # Prints 'Hello, world!'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -98,6 +104,7 @@ so far. Don't worry, that is intentional: giambio never lets a user deal with co
|
||||||
model is much simpler if we take coroutines out of the game, and everything works just the same.
|
model is much simpler if we take coroutines out of the game, and everything works just the same.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|
||||||
import giambio
|
import giambio
|
||||||
|
|
||||||
|
|
||||||
|
@ -118,6 +125,7 @@ As we already learned, async functions can only be called with the `await` keywo
|
||||||
doing so would raise an error, but it's actually a little bit trickier than that. Take this example here
|
doing so would raise an error, but it's actually a little bit trickier than that. Take this example here
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|
||||||
import giambio
|
import giambio
|
||||||
|
|
||||||
|
|
||||||
|
@ -180,6 +188,7 @@ Yep, you read that right. To demnostrate this, have a look a this example
|
||||||
|
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|
||||||
import giambio
|
import giambio
|
||||||
|
|
||||||
|
|
||||||
|
@ -230,6 +239,7 @@ TODO
|
||||||
TODO
|
TODO
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|
||||||
import giambio
|
import giambio
|
||||||
from giambio.socket import AsyncSocket
|
from giambio.socket import AsyncSocket
|
||||||
import socket
|
import socket
|
||||||
|
|
Loading…
Reference in New Issue