1

I'm aware that it is typically not recommended to perform any IO operations inside of a Pydantic validator (see https://github.com/tiangolo/fastapi/issues/979). However, what is not clear to me is if asyncio operations are OK to perform inside of the validator.

For example, if I have a validator that calls await redis.get() is that going to have a significant negative performance hit?

pythonweb
  • 1,024
  • 2
  • 11
  • 26
  • 1
    I don't think you can have async validator https://github.com/samuelcolvin/pydantic/issues/857 the performance hit usually goes the other way, if you call a slow synchronous method from your async code – Anentropic May 25 '22 at 14:44
  • Ah I wasn't aware that you can't use async validators. Looks like I will need to come up with another way to validate from the cache then. – pythonweb May 25 '22 at 19:03

0 Answers0