Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Won't Fix
-
0.9.2
-
None
-
Python, Linux
-
Important
Description
If multiple .thrift files in the same directory share a python namespace and struct definitions exist in more than one of those files, then ONLY the structs in the first targeted .thrift file get generated. Services defined in each file are generated, though, which results in a NameError when importing that service.
Ex:
namespace java com.p.api namespace py p_different.api.net namespace cpp p.api include "../model/Common.thrift" struct ARequest { 1: required i64 ID; } struct AResponse { 1: required i64 ID; } service AService { AResponse save(1: Common.Context ctx, 2: ARequest req) throws (1: Common.Exception e); }
namespace java com.p.api namespace py p_different.api.net namespace cpp p.api include "../model/Common.thrift" struct BRequest { 1: required i64 ID; } struct BResponse { 1: required i64 ID; } service BService { BResponse save(1: Common.Context ctx, 2: BRequest req) throws (1: Common.Exception e); }
The A* service and structs are successfully generated in python and all works well. However, while BService gets generated successfully, when one tries to import BService, a NameError is thrown for BRequest not having a definition.
I've grep'd the genereated sources and sure enough, there's no class declaration for BRequest nor BResponse.
If I append the py namespace with a subnamespace, then all works well, but I wonder if this is the intended behavior which I doubt because the compiler doesn't barf.