GithubHelp home page GithubHelp logo

Comments (3)

ptaoussanis avatar ptaoussanis commented on May 21, 2024

Hi Ikrubner,

This does look like a concurrency issue. You've got multiple threads all trying to print as quickly as they can, and their output is getting mangled together. Think of a room filled with people all shouting at once: you won't be able to hear what anyone's saying because they're all talking over each other.

In particular, this can happen because prn, println, pprint, etc. call (flush) whenever they have something to print. In a single-threaded app, that's usually what you want. But for multi-threaded cases like yours, you'd rather have the output buffered and only (flush)ed as a single atomic output. With the room-of-people analogy, everyone's still shouting together but now at least they're each shouting a complete sentence one at a time without interruption.

I'd start by trying this:
Don't call pprint 3 separate times for each thing you want to output. Each of those 3 calls will (flush), meaning other gook can get interleaved in between. Instead, I'd do something like this:

(let [output (with-out-str (pp/pprint prefix) (pp/pprint message) (pp/pprint more))]
  (print output)
  (flush))

By buffering up the pprint outputs, that also protects against any flushing that may be happening within the pprint calls itself (I just skimmed the source now, not sure if that's necessary or not).

In some cases it can also help to enable :async? for the appender.

Try those out and let me know if you have any luck.

Cheers!

from timbre.

lkrubner avatar lkrubner commented on May 21, 2024

That worked great. Thanks.

from timbre.

ptaoussanis avatar ptaoussanis commented on May 21, 2024

Sure, no problem!

from timbre.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.