FAQ
===

Can I use Faust with Django/Flask/etc.?
---------------------------------------

Yes! Use :pypi:`gevent` or :pypi:`eventlet` as a bridge to integrate with
:mod:`asyncio`.

Using :pypi:`gevent`
~~~~~~~~~~~~~~~~~~~~

This approach works with any blocking Python library that can work
with :pypi:`gevent`.

Using :pypi:`gevent` requires you to install the :pypi:`aiogevent` module,
and you can install this as a bundle with Faust:

.. sourcecode:: console

    $ pip install -U faust[gevent]

Then to actually use :pypi:`gevent` as the event loop you have to either
use the :option:`-L <faust --loop>` option to the :program:`faust` program:

.. sourcecode:: console

    $ faust -L gevent -A myproj worker -l info

or add ``import mode.loop.gevent`` at the top of your entry point script:

.. sourcecode:: python

    #!/usr/bin/env python3
    import mode.loop.gevent

REMEMBER: It's very important that this is at the very top of the module,
and that it executes before you import libraries.


Using :pypi:`eventlet`
~~~~~~~~~~~~~~~~~~~~~~

This approach works with any blocking Python library that can work with
:pypi:`eventlet`.

Using :pypi:`eventlet` requires you to install the :pypi:`aioeventlet` module,
and you can install this as a bundle along with Faust:

.. sourcecode:: console

    $ pip install -U faust[eventlet]

Then to actually use eventlet as the event loop you have to either
use the :option:`-L <faust --loop>` argument to the :program:`faust` program:

.. sourcecode:: console

    $ faust -L eventlet -A myproj worker -l info

or add ``import mode.loop.eventlet`` at the top of your entry point script:

.. sourcecode:: python

    #!/usr/bin/env python3
    import mode.loop.eventlet  # noqa

.. warning::

    It's very important this is at the very top of the module,
    and that it executes before you import libraries.

Can I use Faust with Tornado?
-----------------------------

Yes! Use the ``tornado.platform.asyncio`` bridge:
http://www.tornadoweb.org/en/stable/asyncio.html

Can I use Faust with Twisted?
-----------------------------

Yes! Use the :mod:`asyncio` reactor implementation:
https://twistedmatrix.com/documents/17.1.0/api/twisted.internet.asyncioreactor.html

Will you support Python 3.5 or earlier?
---------------------------------------

There are no immediate plans to support Python 3.5, but you are welcome to
contribute to the project.

Here are some of the steps required to accomplish this:

- Source code transformation to rewrite variable annotations to comments

  for example, the code::

        class Point:
            x: int = 0
            y: int = 0

   must be rewritten into::

        class Point:
            x = 0  # type: int
            y = 0  # type: int

- Source code transformation to rewrite async functions

    for example, the code::

        async def foo():
            await asyncio.sleep(1.0)

    must be rewritten into::

        @coroutine
        def foo():
            yield from asyncio.sleep(1.0)

Will you support Python 2?
--------------------------

There are no plans to support Python 2, but you are welcome to contribute to
the project (details in the question above is relevant also for Python 2).


I get a maximum number of open files exceeded error by RocksDB when running a Faust app locally. How can I fix this?
--------------------------------------------------------------------------------------------------------------------

You may need to increase the limit for the maximum number of open files. The
following post explains how to do so on OS X:
https://blog.dekstroza.io/ulimit-shenanigans-on-osx-el-capitan/


What kafka versions faust supports?
---------------------------------------

Faust supports kafka with version >= 0.10.
