Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

337
Views
Python 3.5: "async with" da como resultado SyntaxError. ¿Por qué?

Estoy usando Python 3.5, que, de acuerdo con PEP 492 , debería tener acceso a la sintaxis async with , pero obtengo un SyntaxError cuando trato de usarlo. ¿Qué estoy haciendo mal?

 In [14]: sys.version Out[14]: '3.5.2 (default, Oct 11 2016, 04:59:56) \n[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)]' In [15]: async with aiohttp.ClientSession() as session: File "<ipython-input-15-9799c5ce74cf>", line 1 async with aiohttp.ClientSession() as session: ^ SyntaxError: invalid syntax
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

No puede usar async with sin la función async . Como dicen los documentos :

Es un SyntaxError usar async con fuera de una función de definición asíncrona.

Pero este código funcionará:

 async def some_function(): async with aiohttp.ClientSession() as session: pass

O echa un vistazo al ejemplo de los documentos .

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!