FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Exception in flask and mod_wsgi app · Issue #180 · pythonnet/pythonnet · GitHub

Repository navigation

Exception in flask and mod_wsgi app #180

Closed

Description

Has anybody managed to successfully run a (non-trivial) Flask app under Apache mod_wsgi using pythonnet ? My app keeps throwing this exception:

"System.TypeInitializationException: The type initializer for 'System.Web.Script.Serialization.JavaScriptSerializer' threw an exception. ---> System.Configuration.ConfigurationErrorsException: Error Initializing the configuration system. ---> System.ArgumentException: The 'ExeConfigFilename' argument cannot be null"

as soon as it tries to use a clr object that deserializes some JSON. Full details here:

http://stackoverflow.com/questions/35872504/pythonnet-exception-the-execonfigfilename-argument-cannot-be-null

On this bug Mono added the mono_domain_set_config API to help with this situation. I don't see that method being called in the Mono code. Neither it seems to be called if I run the code in this other bug through gdb. However the code does not crash, as on the other hand I would expect as my version of Mono does have that bugfix. Still don't quite understand how that bug fix works though if it's not being called. Obviously missing something fairly fundamental here.
Maybe pythonnet PyNet_Init needs to explicitly call mono_domain_set_config ?

Activity

  1. danic commented on Mar 9, 2016

    Author

    It does indeed seem that adding a call to mono_domain_set_config in PyNet_Init fixes the issue:

    diff --git a/src/monoclr/pynetinit.c b/src/monoclr/pynetinit.c
    index eaa1d9c..ed247f2 100644
    --- a/src/monoclr/pynetinit.c
    +++ b/src/monoclr/pynetinit.c
    @@ -31,6 +31,7 @@ PyNet_Args* PyNet_Init(int ext) {
         pn_args->shutdown_name = "Python.Runtime:Shutdown()";
    
         pn_args->domain = mono_jit_init_version(MONO_DOMAIN, MONO_VERSION);
    +    mono_domain_set_config(pn_args->domain, ".", "Python.Runtime.dll.config");
    
  2. added a commit that references this issue on Mar 9, 2016
  3. danic commented on Mar 9, 2016

    Author

    See #181. Travis build failing because it's using an ancient Mono 3.2.8 which does not even have the mono_domain_set_config fix (that was rolled out in 3.8.0). I'm on 4.2.2.

  4. den-run-ai commented on Mar 9, 2016

    Contributor

    @danic see this doc how to update mono on travis ci:

    https://docs.travis-ci.com/user/languages/csharp/

  5. danic commented on Mar 10, 2016

    Author

    @denfromufa saw that thanks. Did try a couple of things on my fork by specifying mono versions but it doesn't work because Travis is using ancient Precise VMs. I did try the new Trusty image but the build hung out and failed. It's kind of irrelevant though as I know my fix works on both distros in fact as I have both a Precise box and a Trusty AWS instance both with Mono 4.2.2. So I'll leave it at that for the time being.

  6. den-run-ai commented on Mar 11, 2016

    Contributor

    @danic maybe it is possible to download latest mono binaries (4.2.2) instead of compiling on build machine? it probably time outs before it builds due to constrained resources.

  7. danic commented on Mar 11, 2016

    Author

    After a few disagreements with Travis I finally managed to persuade it to build it. It works now.

  8. added a commit that references this issue on Mar 15, 2016
  9. added 2 commits that reference this issue on Mar 15, 2016
  10. tonyroberts commented on Mar 15, 2016

    Contributor

    I've re-opened this as the PR was against the wrong branch. Please submit a new PR against the develop branch.

  11. tonyroberts commented on Mar 15, 2016

    Contributor

    Done - see PR #189

  12. added a commit that references this issue on Mar 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL