jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.18.7 | Fund Crystals development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
Philpax has quit [Read error: Connection reset by peer]
Philpax has joined #crystal-lang
<devinacosta> Is there a less expensive way in a program to have the program sleep, than using just sleep(seconds)?
<devinacosta> I'm noticing that my program uses 100% of the CPU just sleeping.
<devinacosta> 25771 root 20 0 178324 2252 1056 R 100.0 0.0 0:27.30 vzcheck
<tilpner> devinacosta - How long is it sleeping each time?
<devinacosta> Right now I have it sleep 60 seconds.
<devinacosta> I'm basically having to check like 30 websites and then sleep a minute and recheck.
Oliphaunte has joined #crystal-lang
<devinacosta> Is there a better way so it's not cpu bound?
<tilpner> You must be doing something else or more. A simple sleep in a loop will not cause 100% CPU usage.
<devinacosta> Maybe it's the non-stop loop then?
<tilpner> How much code do you have?
<devinacosta> I create a Fiber for each of my web checks, and then have it sleep a minute.
<devinacosta> Then I have at the bottom:
<devinacosta> While True:
<devinacosta> Fiber.yield
<devinacosta> done
<tilpner> Yes, that looks like it would cause this.
Oliphaunte has quit [Ping timeout: 250 seconds]
<devinacosta> Tilpner: is there a more correct way of doing it?
<devinacosta> I have the program daemonizing.
<tilpner> Why do you have the yield loop there?
<devinacosta> I just figured it needed to be in the loop?
<tilpner> It should not be necessary.
<tilpner> No yield at all, actually.
datanoise has joined #crystal-lang
<devinacosta> Tilpner: this is my code:
<tilpner> Huh. Does that even work? It doesn't look like it should.
<tilpner> Why are you not using Crystal sleep?
<tilpner> https://crystal-lang.org/api/0.18.7/Fiber.html#sleep%28time%29-instance-method
<tilpner> Or https://crystal-lang.org/api/0.18.7/Fiber.html#sleep%28time%29-class-method
<devinacosta> I initially didn't have the libC section
<devinacosta> Just tried to see if that makes a difference, If I take out same issue
<tilpner> devinacosta - Replace that "while true Fiber.yield end" loop with "sleep".
<devinacosta> Sweet, I put: loop { sleep }
<devinacosta> That seems to have fixed it.
<tilpner> Just sleep will do.
<devinacosta> Oh ok... Most of the examples I seen that was using that daemonize.cr showed having loop { something }
<devinacosta> Thanks a lot for your help.
ome has joined #crystal-lang
<tilpner> :)
matp has quit [Remote host closed the connection]
devinacosta has quit [Quit: Page closed]
Oliphaunte has joined #crystal-lang
<tilpner> Uhm... any idea what I can do about XML?
<tilpner> Short of writing the parsing code myself, which could actually be interesting.
Oliphaunte has quit [Ping timeout: 244 seconds]
<tilpner> Embarassing. I should try the XML module before asking... :(
pawnbox has quit [Ping timeout: 272 seconds]
datanoise has quit [Ping timeout: 258 seconds]
datanoise has joined #crystal-lang
Oliphaunte has joined #crystal-lang
Oliphaunte has quit [Read error: Connection reset by peer]
Oliphaunte has joined #crystal-lang
pawnbox has joined #crystal-lang
ome has quit [Quit: Connection closed for inactivity]
Oliphaunte has quit [Read error: Connection reset by peer]
Oliphaunte has joined #crystal-lang
pawnbox has quit [Ping timeout: 264 seconds]
Oliphaunte has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 244 seconds]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
Oliphaunte has joined #crystal-lang
Oliphaunte has quit [Ping timeout: 240 seconds]
pawnbox has quit [Remote host closed the connection]
devinacosta has joined #crystal-lang
pawnbox has joined #crystal-lang
<devinacosta> question when i'm doing an HTTP::Client.get, what would be the proper way to set a timeout?
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
<tilpner> devinacosta - Do you mean https://crystal-lang.org/api/0.18.7/HTTP/Client.html#connect_timeout%3D%28connect_timeout%3ATime%3A%3ASpan%29-instance-method ?
<tilpner> (Or the corresponding read_timeout...)
<devinacosta> ahhh ok i'll look at that.. right now i'm just calling HTTP::Client.get "url"
<devinacosta> it looks like it may have hard coded a 60 second timeout.
<devinacosta> doesn't look like it can be changed?
<devinacosta> so maybe i need to try this other method of calling it.
pawnbox has quit [Remote host closed the connection]
devinacosta has quit [Ping timeout: 250 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
wiiw has quit [Remote host closed the connection]
Oliphaunte has joined #crystal-lang
pawnbox has quit [Read error: Connection reset by peer]
Oliphaunte has quit [Ping timeout: 250 seconds]
pawnbox has joined #crystal-lang
soveran has joined #crystal-lang
Oliphaunte has joined #crystal-lang
Oliphaunte has quit [Ping timeout: 252 seconds]
matp has joined #crystal-lang
pawnbox has quit [Ping timeout: 276 seconds]
pawnbox has joined #crystal-lang
mark_66 has joined #crystal-lang
pawnbox_ has joined #crystal-lang
pawnbox has quit [Ping timeout: 276 seconds]
pawnbox_ has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
datanoise has quit [Ping timeout: 258 seconds]
wiiw has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
Yxhuvud has quit [Remote host closed the connection]
Yxhuvud has joined #crystal-lang
datanoise has joined #crystal-lang
datanoise has quit [Ping timeout: 240 seconds]
Philpax has quit [Ping timeout: 272 seconds]
<jhass> tilpner: all crystal XML parser lib would very interesting indeed though..
<jhass> looking at all the CVE's libxml2 gets...
<tilpner> A streaming parser too, but those are always more annoying to work with, so I'm glad this one goes with a DOM model.
<tilpner> It just didn't occur to me that someone would put this in their standard library, so I didn't think of looking there. :)
<FromGitter> <deepj> What Oga instead of libxml2? https://github.com/YorickPeterse/oga That could be ported to Crystal
datanoise has joined #crystal-lang
datanoise has quit [Ping timeout: 244 seconds]
<jhass> well, the core of oga is a ragel parser
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
<RX14> i much prefer simple lexers and then recursive descent for parsing personally
<RX14> guess it depends on what you are parsing
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
Philpax has joined #crystal-lang
<jhass> well, you certainly want to parse XML deeper than your stack limit, given what people do to XML...
<tilpner> The solution is obviously to increase your stack depth limit! /s
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
datanoise has joined #crystal-lang
datanoise has quit [Ping timeout: 276 seconds]
pawnbox has quit [Read error: Connection reset by peer]
pawnbox has joined #crystal-lang
Oliphaunte has joined #crystal-lang
Oliphaunte has quit [Remote host closed the connection]
Oliphaunte has joined #crystal-lang
Kurisu has joined #crystal-lang
Oliphaunte has quit [Remote host closed the connection]
Oliphaunte has joined #crystal-lang
Kurisu has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
pawnbox has quit [Remote host closed the connection]
Kurisu has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
Oliphaunte has quit [Remote host closed the connection]
datanoise has joined #crystal-lang
datanoise has quit [Ping timeout: 276 seconds]
Oliphaunte has joined #crystal-lang
cristianoliveira has joined #crystal-lang
datanoise has joined #crystal-lang
Kurisu has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Kurisu has joined #crystal-lang
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
buggs1 is now known as buggs
Philpax has quit [Ping timeout: 252 seconds]
pawnbox has quit [Ping timeout: 252 seconds]
Raimondii is now known as Raimondi
pawnbox has joined #crystal-lang
soveran has quit [Remote host closed the connection]
datanoise has quit [Quit: WeeChat 1.5]
soveran has joined #crystal-lang
soveran has quit [Remote host closed the connection]
mark_66 has quit [Remote host closed the connection]
Kurisu has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Kurisu has joined #crystal-lang
Kurisu has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
pawnbox has quit [Remote host closed the connection]
Kurisu has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
pawnbox has joined #crystal-lang
soveran has quit [Ping timeout: 250 seconds]
Kurisu has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
daemonwrangler has quit [Ping timeout: 272 seconds]
Kilo`byte has quit [Ping timeout: 272 seconds]
Raimondii has joined #crystal-lang
mroth has quit [Ping timeout: 272 seconds]
jhass has quit [Ping timeout: 272 seconds]
jnylen has quit [Ping timeout: 272 seconds]
Oliphaunte has quit [Remote host closed the connection]
CompanionCube has quit [Ping timeout: 272 seconds]
Oliphaunte has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
mroth has joined #crystal-lang
xxxx has joined #crystal-lang
Kilo`byte has joined #crystal-lang
jnylen has joined #crystal-lang
daemonwrangler has joined #crystal-lang
wiiw has quit [Ping timeout: 240 seconds]
xxxx is now known as wiiw
jhass has joined #crystal-lang
Raimondii is now known as Raimondi
CompanionCube has joined #crystal-lang
CompanionCube has quit [Changing host]
CompanionCube has joined #crystal-lang
<BlaXpirit> how bad is it to rely on the address of an object being the address of its first item - 4 ?
<BlaXpirit> first member *
<jhass> well it's nothing you'll ever get as a contract I'd say
<jhass> but if you have some way to monitor it still holds true, it's probably ok
<BlaXpirit> that's an idea
<BlaXpirit> thanks
<BlaXpirit> i keep wanting an assert statement that is a no-op in release mode
<BlaXpirit> I suppose it's one simple macro away, but it's not as nice
pawnbox has quit [Remote host closed the connection]
Oliphaunte has quit [Remote host closed the connection]
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/vKVsf
<crystal-gh> crystal/master db7c8f8 Ary Borenszweig: Merge pull request #3009 from crystal-lang/feature/to_pretty_json_indent...
Oliphaunte has joined #crystal-lang
matp has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
Oliphaunte has quit [Remote host closed the connection]
Oliphaunte has joined #crystal-lang
<crystal-gh> [crystal] jhass closed pull request #2993: Add support for LLVM 3.8 (master...llvm-3.8) https://git.io/vK4S9
matp has joined #crystal-lang
eserror has joined #crystal-lang
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/vKV4J
<crystal-gh> crystal/master 19ddb4c Ary Borenszweig: Fixed Makefile to work with LLVM 3.8. Related to #2993
<travis-ci> crystal-lang/crystal#5859965 (master - Merge pull request #2993 from omarroth/llvm-3.8): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/145626664
<FromGitter> <sdogruyol> I'm trying to compile Crystal master with LLVM 3.8 and getting this error in ./src/compiler/crystal/codegen/debug.cr:214: undefined constant LibLLVM::IS_36 ⏎ ⏎ {% if LibLLVM::IS_36 || LibLLVM::IS_35 %}
fryguy9 has joined #crystal-lang
soveran has joined #crystal-lang
<jhass> huh
<FromGitter> <sdogruyol> OS 10.11 btw
<jhass> does it work if you add a require "llvm/lib_llvm" to src/compiler/crystal/codegen/debug.cr
<jhass> ?
<FromGitter> <sdogruyol> lemme try
<FromGitter> <sdogruyol> ```require "./codegen" ⏎ require "llvm/lib_llvm"``` [https://gitter.im/crystal-lang/crystal?at=578d306475045f8767f1586b]
<jhass> yeah
<FromGitter> <sdogruyol> in ./src/compiler/crystal/codegen/debug.cr:215: undefined constant LibLLVM::IS_36 ⏎ ⏎ {% if LibLLVM::IS_36 || LibLLVM::IS_35 %}
<FromGitter> <sdogruyol> the same error
<jhass> very weird
<FromGitter> <sdogruyol> llvm-config --version ⏎ 3.8.1
<jhass> it's right there
<jhass> it works on travis
<jhass> it worked for omarroth
<FromGitter> <sdogruyol> let me check
<jhass> it apparently worked for Ary
<jhass> it works for me
<travis-ci> crystal-lang/crystal#19ddb4c (master - Fixed Makefile to work with LLVM 3.8. Related to #2993): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/145629627
<FromGitter> <sdogruyol> i dunno it's there for sure IS_36 = {{LibLLVM::VERSION.starts_with?("3.6")}}
<FromGitter> <sdogruyol> c++ -c -o src/llvm/ext/llvm_ext.o src/llvm/ext/llvm_ext.cc `/usr/local/opt/llvm/bin/llvm-config --cxxflags` ⏎ cc -fPIC -c -o src/ext/sigfault.o src/ext/sigfault.c ⏎ ar -rcs src/ext/libcrystal.a src/ext/sigfault.o ⏎ CRYSTAL_CONFIG_PATH=`pwd`/src ./bin/crystal build -o .build/crystal src/compiler/crystal.cr -D without_openssl -D without_zlib [https://gitter.im/crystal-lang/crystal?at=578d31df841e619d16ffb33a]
<jhass> I'm a bit clueless here :/
<FromGitter> <sdogruyol> me too
<FromGitter> <sdogruyol> anything that i can do to debug this further?
<FromGitter> <sdogruyol> or shall i open an issue
<jhass> as said I'm clueless
<FromGitter> <sdogruyol> thanks, i've opened an issue
<crystal-gh> [crystal] jhass pushed 1 new commit to master: https://git.io/vKVKq
<crystal-gh> crystal/master 63ca495 Jonne Haß: Prefer llvm-config if it points to 3.8 in Makefile
<FromGitter> <sdogruyol> well, is that because that i try to compiled master with 0.18.7?
<FromGitter> <sdogruyol> compile*
<jhass> nah, I tested it like that
<jhass> travis does it too
<jhass> @sdogruyol ^
Ven has joined #crystal-lang
<travis-ci> crystal-lang/crystal#63ca495 (master - Prefer llvm-config if it points to 3.8 in Makefile): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/145648431
eserror has quit [Read error: Connection reset by peer]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
fryguy91 has joined #crystal-lang
fryguy9 has quit [Ping timeout: 252 seconds]
Oliphaunte has quit [Remote host closed the connection]
fryguy91 has quit [Quit: Leaving.]
soveran has quit [Remote host closed the connection]
cristianoliveira has quit [Ping timeout: 272 seconds]
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 240 seconds]
tomchapin has joined #crystal-lang
tomchapin has quit [Client Quit]
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
soveran has quit [Remote host closed the connection]
<BlaXpirit> sigh, I realized too late that converting a pointer to a crystal object may not make sense https://carc.in/#/r/14a7
<BlaXpirit> this is surprising though https://carc.in/#/r/14aa
<BlaXpirit> it should be possible to recover the type info
CompanionCube has quit [Quit: ZNC - http://znc.in]
<BlaXpirit> and it is https://carc.in/#/r/14ag
<BlaXpirit> where's A+ when you need it
<BlaXpirit> now this is a real WTF https://carc.in/#/r/14ak
<BlaXpirit> no, sorry, just forgot the "p"
<BlaXpirit> anyhow, .as(Union(A)) works like a charm
<FromGitter> <aurelien-ldp> Hello ! Is there any way to call a method from a Macro::Def object ?
<FromGitter> <aurelien-ldp> I mean I get method from @type.methods in macro and I want to store it as a Proc for example
<BlaXpirit> try .resolve
<BlaXpirit> oh wait no, you can't do it like that
<BlaXpirit> probably have to reconstruct the path and then just ->{ {{path}} }
<BlaXpirit> but sorry, gotta go.
deverly has joined #crystal-lang
<FromGitter> <aurelien-ldp> thank you for your answer, I will try
deverly has quit [Client Quit]
CompanionCube has joined #crystal-lang
CompanionCube has quit [Changing host]
CompanionCube has joined #crystal-lang
<FromGitter> <aurelien-ldp> I’m not sure it is a good practice but `->{ {{method.body}} }` actually works
<BlaXpirit> that will break so easily
<BlaXpirit> i meant more like ->{ Class.{{method.name}} }